Call method in ui-sref in angularJS
I have code in ngGrid:
cellTemplate: '<div class="padding-t-5 padding-l-5"><a ui-sref="editCamera({id:row.entity.id})" ><i class="fa fa-edit margin-r-10"></i></a>\n\
<button ng-click="confirmClick() && grid.appScope.deleteRow(row)" confirm-click><i class="fa fa-trash"></i></button></div>'
I am wondering how to define the editCamera method mentioned in ui-sref in a controller.
If I add ng-click, then how would I pass the identifier (transmitted by ui-sref)
I tried to define using $ scope.editCamera, but dont worked.
**** UPDATE ******
I need to perform add and edit operations in one controller, for this I need another method for the edit operation.
+4
3 answers
ng-click ui-sref
HTML
<div class="padding-t-5 padding-l-5">
<a ng-click="editCamera(row.entity.id)">
<i class="fa fa-edit margin-r-10"></i>
</a>
<button ng-click="confirmClick() && grid.appScope.deleteRow(row)" confirm-click>
<i class="fa fa-trash"></i>
</button>
</div>
JS
$scope.editCamera = function(id) {
$state.go('INSERT-EDIT-CAMERA-STATE-NAME-HERE', {id: id});
}
- , ui-sref, , , href, , - , . .
+1