html5 - Add button to ionic footer in specific controller -
i want add command button in 2 side of ionic footer in many of controller. example in firstcontroller want add , edit button , in secondcontroller want remove , send button.
i add main layout static:
<div class="bar bar-footer bar-balanced"> <div class="title">my program</div> <button class="button button-outline button-light" ng-click="add()"><i class="ion-arrow-left-c"></i></button> <button class="button button-outline button-light" ng-click="edit()"><i class="ion-arrow-right-c"></i></button> </div>
please guide me how in ionic framework , angular.
thanks attention
my approach :
move code add , edit buttons, , remove , send button different service [1st , 2nd service].
create middle man service, containing references both of services declared above [3rd service].
this service contain 2 generic methods, i.e. method1 , method2.
now in controllers, add reference 3rd service.
yourapp.controller("mycontroller", function(thirdservice) { $scope.thirdservice = thirdservice; $scope.textforbutton1 = "text based on controller"; $scope.textforbutton2 = "text based on controller"; });
now, in html :
<div class="bar bar-footer bar-balanced"> <div class="title">my program</div> <button class="button button-outline button-light" ng-click="thirdservice.handlefirstbutton()"><i class="ion-arrow-left-c">{{textforbutton1}}</i></button> <button class="button button-outline button-light" ng-click="thirdservice.handlesecondbutton()"><i class="ion-arrow-right-c">{{textforbutton2}}</i></button> </div>
assuming each of controllers mapped pages referenced in different routes, can decide method invoke based on route.
i.e. in third service :
app.service('thirdservice', function($http, $location, $state) { this.handlefirstbutton = function() { switch ($state.current.name.tostring().tolowercase().trim()) { } }; this.handlesecondbutton = function() { switch ($state.current.name.tostring().tolowercase().trim()) { } }; });
Comments
Post a Comment