大佬教程收集整理的这篇文章主要介绍了angularjs – ng -inc with $state.go()来自ui-router无法正常工作,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<ng-include src="'app/components/widgets/buttonbar.html'"></ng-include>
这包括来自/ 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') } }
像我的客户列表那样:
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') }) }
(从模式开始,使用github上的pineconellc的ui-foundation)
buttonSvc.addButton('goBACk','Go BACk','toTheGrid()',2)
但是,此按钮无效,此代码生效:
$scope.toTheGrid = function(){ $state.go('customers.list') }
如果我只是制作一个常规按钮并使用该功能,它工作正常.所以我有一个问题.
由于我现在已经获得了赏金,如果您想查看更多代码,请询问并发布相关来源.
<button ng-click="foo()">click</button> <button ng-click="{{'foo()'}}">click</button>
第一次工作,第二次没有. (生成的html是一样的)
见plunk:http://plnkr.co/edit/znFa6lGUGmQ0bYw097zH?p=preview
原因很简单 – 在第二种情况下,’foo()’被视为基本字符串.
以上是大佬教程为你收集整理的angularjs – ng -inc with $state.go()来自ui-router无法正常工作全部内容,希望文章能够帮你解决angularjs – ng -inc with $state.go()来自ui-router无法正常工作所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。