我有这个:
<ng-include src="'app/components/widgets/buttonbar.html'"></ng-include>@H_404_2@这包括来自/ customers路由和/ customers /:id路由的按钮.我可以动态添加带动作的按钮.当我去客户时,我使用此服务界面添加按钮:
this.buttons = [] this.addButton = function(id,title,classes,href,action,sortOrder){ console.log(this.buttons) var button = {}; var pushViable = true; button.id = id button.title = title button.classes = classes button.href = href button.action = action button.sortOrder = sortOrder angular.forEach(this.buttons,function(index,sort){ if(button.sortOrder === sort){ toastr.error('Button Sort Order Exists') pushViable = false; } }) if(pushViable === true){ this.buttons.push(button) this.buttons = sortButtons(this.buttons) $rootScope.$broadcast('buttonBar:update') } }@H_404_2@像我的客户列表那样:
buttonSvc.addButton('newCustomer','New Customer','button small','#','newCustomer()',0) $scope.newCustomer = function(){ var customerModal = $modal.open({ templateUrl: 'app/customers/newCustomer.html',controller: 'customerModalCtrl',windowClass: 'small' }) customerModal.result.then(function(){ $rootScope.$broadcast('customer:update') }) }@H_404_2@(从模式开始,使用github上的pineconellc的ui-foundation)
buttonSvc.addButton('goBack','Go Back','toTheGrid()',2)@H_404_2@但是,此按钮无效,此代码生效:
$scope.toTheGrid = function(){ $state.go('customers.list') }@H_404_2@如果我只是制作一个常规按钮并使用该功能,它工作正常.所以我有一个问题.
由于我现在已经获得了赏金,如果您想查看更多代码,请询问并发布相关来源.