$ state.go()我有這樣的:NG-包括與UI的路由器不能正常工作
<ng-include src="'app/components/widgets/buttonbar.html'"></ng-include>
這包括同時從/客戶路線和/客戶/按鈕:身份證路線。我可以動態地添加按鈕。當我將我的客戶增加使用這項服務界面按鈕:
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')
}
}
像這樣從我的customerlist:
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')
})
}
(從模式這樣做與UI的基礎工程從pineconellc GitHub上)
buttonSvc.addButton('goBack','Go Back', 'button small', '#','toTheGrid()',2)
此按鈕,但不影響正常工作,使用此代碼:
$scope.toTheGrid = function(){
$state.go('customers.list')
}
如果我只是做一個常規的按鈕,並使用該功能,它工作正常。所以我有一個問題。
正如我現在放置一個賞金,如果你想看到更多的代碼,請問,我會發布相關的來源。
看不到圖片,你是否也可以提供涉及此事的其他源代碼?謝謝 – Renesansz
[這裏是一個鏈接](https://gist.github.com/dkran/b530625ee18bc8706106),其中包含我正在與之交互的buttonbar服務控制器和模板。我可以在一秒鐘內添加一些其他的東西。謝謝。 – dkran
看起來你在這裏傳遞的函數是一個字符串'buttonSvc.addButton('goBack','返回','按鈕小','#','toTheGrid()',2)'你可以刪除單個圍繞'toTheGrid()'函數引用並重試?如果仍然不起作用,請嘗試刪除括號'()'。然後讓我知道發生了什麼事。謝謝 – Renesansz