I have implemented two modules module-1 and module-2 within my Angular application.
Within module-1, I have defined a factory as shown below:
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;
}
};
});
In module-2, there is a controller where the validateOwner function is called upon clicking:
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()">
The problem arises when clicking the Next button multiple times - the validateOwner function is not triggered after the initial click. Could this be due to Angular caching the results?