单击时 angular-ui 引导程序选项卡选择功能
问题描述:
我正在尝试使用 angular ui bootstrap 在选项卡选择上调用表达式函数,但是该表达式未被调用,但在 angular Inspector 上检查函数/expression 是否存在:以下是我的代码工作:
Am trying to call an expression function on tab select using angular ui bootstrap, however the expression is not being called but checking on angular inspector the function /expression exists : below is my code work:
注意:其他标签正常运行
NB : Other tabs function correctly
角度视图
<uib-tab ng-click="vm.alertMe" select="" heading="New Invoice">
.....
</uib-tab>
控制器用作虚拟机
vm.alertMe = alertMe;
function alertMe() {
setTimeout(function() {
$window.alert('You\'ve selected the alert tab!');
});
}
答
始终注入您在 Angular 应用程序中使用的基本服务名称,在上面的示例中,我没有调用: $window
服务导致错误/错误.我的最终控制器如下:
Always inject the base service names you use in your angular app ,in the above example i was not calling : $window
service which resulted in the bug / error .my final controller is as following :
function() {
'use strict';
angular
.module('app.patients')
.controller('PatientsController', PatientsController);
PatientsController.$inject = ['$http','$window'];
/* @nginject */
function PatientsController($http, $window) {
vm.alertMe = function() {
$window.alert('You\'ve selected the alert tab!');
}
}
}
和视图,
<uib-tab select="vm.alertMe()" heading="New Invoice">
.....
</uib-tab>