单击时 angular

编程入门 行业动态 更新时间:2024-10-28 16:16:20
本文介绍了单击时 angular-ui 引导程序选项卡选择功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试使用 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>

这篇关于单击时 angular-ui 引导程序选项卡选择功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-21 06:11:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/997562.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   angular

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!