Angularjs to pass multiple params -
i want update status information need pass 2 params 1 school_id , other 1 status may be(approved, pending , declined) depending on user clicks button. have table school_info fields id school_name status in applicationjs need pass 2 params id , status. here html code, have ng-repeat using school in schools.
<a href="#/changestatus/{{school.id}}/approved"><button class="btn btn-success" ng-model="approve">approve</button></a> <a href="#/changestatus/{{school.id}}/declined"><button class="btn btn-danger" ng-model="decline">decline</button><a> <a href="#/changestatus/{{school.id}}/pending"><button class="btn btn-deafult" ng-model="pending">pending</button></a>
my app.js code is
var app=angular.module("admin",[]); app.config(function ($routeprovider) { $routeprovider .when('/', { templateurl: 'home.php', controller: 'adminctrl' }).when('/changestatus/:id/:sts',{ templateurl:'home.php', controller:'adminctrl' }).when('/mapview/:id',{ templateurl:'mapview.html', controller:'mapctrl' }).otherwise({ redirectto: "/" }); }); app.controller("adminctrl",function($scope,$http,$routeparams){ var sts=$routeparams.status; var id=$routeparams.id; console.log("sts"+sts+id); //here want 2 params fetched inside console log. when clicked on specific btn.i have seen previous questions asked on multiple params passing there must easy way out multiple params. });
please use ng-href
instead of href
, hrefs should below, no need of :
<a ng-href="#/changestatus/{{school.id}}/approved"><button class="bt...... <a ng-href="#/changestatus/{{school.id}}/declined"><button class="btn btn...
then in controller,
var sts=$routeparams.sts; // u need sts , //because sts in .when('/changestatus/:id/:sts'.. var id=$routeparams.id; console.log("sts"+sts); console.log("id"+id);
Comments
Post a Comment