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
Post a Comment