我有兩個模塊模塊-1和模塊-2在我的角應用程序。角度工廠功能只執行一次
在模塊-1,我已經創建了一個工廠
angular.module('ui.campaign.manager').factory('validate',['the',function(the) {
return {
validateOwner: function(scope) {
console.log(scope.campaign);
if(!scope.campaign.owner) {
scope.view = true;
scope.errormsg = "Error : Campaign owner is a mandatory field. Please select one from the dropdown menu.";
return false;
}
return true;
}
};
}]);
在模塊-2,還有就是我呼籲這個功能的控制器NG單擊
var campaignApp = angular.module('module-2',[ 'module-1']);
campaignApp.controller('campaignDetailController', function($scope, validate) {
scope.submitCampaignPage = function(){
validate.validateOwner($scope);
}
});
<input class="btn btn-primary" type="submit" value="Next" name="campdetailsnext" ng-click="submitCampaignPage()">
現在,問題是,當我點擊下一步按鈕validateOwner功能第一次在後續的點擊中調用正確,submitCampaignPage函數被調用,但validateOwner函數根本沒有被調用。
角度緩存結果?
控制檯日誌中的任何錯誤?請添加完整模塊配置,其中定義了'scope.submitCampaingPage'。 – lin
不,控制檯日誌中沒有錯誤 – user3587856
請添加請求的代碼。 'console.log(scope.campaign);'工作 - >寫輸出嗎? – lin