asp.net mvc 4 - Parameter is null in controller when using $routeProvider in angularjs -


routing

 .when('/student/:id', {            templateurl: 'student/index',            controller: 'studenteditctrl'        }) 

my link contains

<a class="btn btn-primary" ng-href="#/student/@v.id">edit</a> 

my angular controller

angular.module('newapp')   .controller('studenteditctrl', ['$scope', function ($scope, $stateparams) {       $scope.istabactive = true;        $scope.id = $stateparams.id;       alert("studenteditctrl");   }]); 

i have used $routeparams instead $stateparams.

my mvc controller

  public actionresult index(int? id)         {             student st = new student();             if (id != null)                 st = srepository.students.firstordefault(c => c.id == id);             return view(st);         } 

in asp.net mvc controller id null,

i think should change link to:

<a class="btn btn-primary" ng-href="#/student/{{id}}">edit</a> 

presuming sits within scope of studenteditctrl.

and use $routeparams


Comments

Popular posts from this blog

apache - setting document root in antoher partition on ubuntu -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1 -