gpt4 book ai didi

angularjs - 在相同的Controller Angular Js中将函数调用到另一个函数中

转载 作者:行者123 更新时间:2023-12-04 05:17:33 25 4
gpt4 key购买 nike

我是刚开始使用angularjs的人,我已经在 Controller 中声明了两个函数,现在我想将一个函数用于另一个函数,我该怎么做
表示如果我在另一个函数中说函数名,则说未定义。

这是代码:

'use strict';
angular.module('customer').controller('Controller', ['$scope', '$state', 'Sservice',
function($scope, $state, Sservice) {

var that = this;

(function getDetails() {
//IMPLEMENTATION
}());

this.function2 = function function2 (id){
//implementation
getDetails(); // says undefined
};
}
]);

最佳答案

.controller('SampleController',function($scope){
$scope.funcA = function(){
$scope.funcB();//scope level function
funcC(); //non scope level function``
}
$scope.funcB = function(){
}
var funcC = function(){
}
});

关于angularjs - 在相同的Controller Angular Js中将函数调用到另一个函数中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30663554/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com