I have a problem, when I edited data, my url not showing id example : /answer/1 or /answer/2 or /answer/3
etc. Im confused because Im using UI ROUTER
I'm a beginner use UI ROUTER angularjs. Can you help me ? What should I do ? Thanks
My routing code :
.state({
name: 'answer',
url : '/answer/',
params : {
obj : null
},
controller: 'answer-controller',
templateUrl: 'templates/table-answer.html'
})
ng-click go to table-answer :
<button type="button" class="btn btn-default" ng-click="ListAnswer(data.item)"><i class="fa fa-eye"></i> View Answer</button>
Pass params $scope.ListAnswer into answer-controller.js
$scope.ListAnswer = function(data) {
$state.go('answer', {obj : data});
};
It's quite simple. Only one thing you missed there, otherwise your code is right.
Now there are two ways to go over that state.
//Html
//Controller
OR
Your state needs altering slightly:
Change your code slightly to pass along the id in the url of links:
If you want to access the parameter from your controller however, you'll have to use $stateParams, so in this case, $stateParams.itemId