3gwebtrain 3gwebtrain - 1 year ago 247
AngularJS Question

UI-router throw error as `Invalid state ref`, when adding link to `ui-sref'

for the following


.state('user', {
templateUrl : 'app/views/pages/user/user.html',
controller : 'userController as user',
required : true,
resolve : {
userData : function( $q, api, $stateParams ){

console.log('hi', $stateParams)

var differed = $q.defer();

api.getUsers().then(function( data ){
differed.resolve( data.data );

return differed.promise;


I am calling from one of my html as like this:

<li ng-repeat="user in users.usersData"><a ui-sref="user(userId:{user._id})">{{user.name}}</a></li>

But getting error as :

angular.js:13920 Error: [$parse:syntax]


what is wrong with my code? any one help me here?

Answer Source

The ui-sref


should be like


what we pass is an object with property named userId and value coming from user._id: {userId:user._id}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download