angularjs - How to use diffrent function for different routes from one Controller in Angular JS? -


can define in ui-router routes function has call on particular routes 1 controller? have 2 functions in controller , both different. -

app.controller('mainctrl',function($scope, $stateparams){       $scope.firstfunction = function () {         $scope.firstvar = 'hello there';     };      $scope.secondfunction = function () {         $scope.secondvar = 'i learning angular js!';     };  })  

i want use firstfunction or secondfunction diffrent routes -

adsyogiapp.config([ '$stateprovider','$urlrouterprovider',      function ($stateprovider, $urlrouterprovider) {             $stateprovider             .state('app.first', {  // route want use mainctrl's firstfunction                 url: "/firstpage",                  templateurl : 'views/firstpage.html',                 controller: "mainctrl"             })             .state('app.second', {  // route want use mainctrl's secondfunction                 url: "/firstpage",                  templateurl : 'views/firstpage.html',                 controller: "mainctrl"             });      } ]); 

how ?


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -