angularjs功能在控制器功能中

时间:2018-04-05 14:21:24

标签: angularjs

在我的angularjs中,我在控制器功能中有一些功能,如下所示。

$scope.TestFn = {
    Detail: function() {
        console.log('in Detail function');                          
        },
    LIBset: function(index) {
        console.log('in LIBset function');
        $scope.SelRow = index;
        },
    LibSplit: function() {
            console.log('in LibSplit function');    
            // Some Code                    
        }
}
$scope.EleFn = {
    Comments: function() {
            console.log('in function Comments');
            //some code                 
        },
    Implement: function() {
            console.log('in function Implement');
            //some code     
        }
}

我在第一个htm模板中使用的第一组函数($ scope.TestFn),如下所示,

<tr ng-repeat="x in TestFn.LibSplit() track by $index">
        <td><input type="text" class="inputtxt" ng-model="x"></td>
</tr>

我在其他html模板中使用的其他set($ scope.EleFn)。当我点击链接加载第一个模板时它工作正常,但当我点击seocnd链接加载第二个html模板时,不必要地调用函数“LibSplit”。我显然没有在我的第二个html模板中调用此函数。当我再次点击第二个链接时,不会调用此功能。我的观察是,只有当我点击第一个链接然后再点击第二个链接时才会发生对此libsplit功能的不必要调用。

这种角度行为可能是什么原因以及如何解决这个问题?另外请告诉我们我们所说的这种功能安排。

我希望我可以创建一个plunkr或jsfiddle,但我不确定我是否能够重现这个问题。

由于

0 个答案:

没有答案