I have controller with method that does AJAX request:
.controller('EditProfileController', ['$scope', '$http') {
// Do AJAX query here
// Some methods for update profile
}]);
Also I have $routeProvider in this Angular JS file:
.config(function ($routeProvider) {
$routeProvider
.when('/profile/personal/:type', {
templateUrl: '/personal.html',
controller: 'EditProfileController'
})
}
Problem is that when I open page with URL /profile/personal/:type it calls again controller EditProfileController and calls AJAX method inside.
How I can fix it?
HTML code:
<div ng-controller="EditProfileController">
<!-- Here are loaded data from AJAX response
</div>
Solution:
Problem was in double ng-view in template:
<div ng-show="isLoaded" ng-view></div>
<div ng-show="!AILoading" ng-view></div>