相关疑难解决方法(0)

在angularjs控制器内调用两次函数

我是角度js的新手,目前仍然坚持使用非常有线的bug.控制器中的函数在通过路径加载的视图调用时运行两次.

http://jsfiddle.net/4gwG3/5/

你会看到警报两次!!

我的观点很简单

我的应用程序代码如下

var IB = angular.module('IB', []);    

//channel controller
IB.controller('channelsController', function ($scope, $routeParams) {
    $scope.greet = function () {
        alert('hi');
    };
});


IB.config(function ($routeProvider) {
    $routeProvider
    .when('/channels', {
        controller: 'channelsController',
        template: '{{greet()}}'
    })

    .otherwise({ redirectTo: '/channels' });

});
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-scope

22
推荐指数
1
解决办法
3万
查看次数

当满足某些`*ngIf`条件时,如何从类装饰器调用某个方法?

当*ngIf满足某些条件时,如何从类装饰器调用某个方法.我有一个完全像AngularJS问题的场景,其中使用ng-init()但ng-init不是Angular2的一部分

<div *ngIf="obj.someProperty" callSomeMethod() >
 <!--render inner parts-->
</div>
Run Code Online (Sandbox Code Playgroud)

typescript angular

6
推荐指数
1
解决办法
880
查看次数

标签 统计

angular ×1

angularjs ×1

angularjs-scope ×1

typescript ×1