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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -