user2925894
user2925894

Reputation: 259

AngularJS, my function won't redirect to new page

My angularJs function won't redirect to new page because $location is undefined.

Here is my controller.js:

wikiControllers.controller('articleController', ['$scope', 'articleService', '$routeParams', '$sanitize', 
function($scope, articleService, $routeParams, $sanitize, $location){

$scope.deleteArticle = function(){
  //articleService.deleteArticle(this.article);
  $location.path("/hjem");
}
  }]);

My button in .html:

<button ng-click="deleteArticle()" ng-confirm-click="Er du sikker på at du vil slette dette?">Slett artikkel</button>

Also the ng-confim-click won't show some kind of confirm box.

Upvotes: 0

Views: 706

Answers (1)

idursun
idursun

Reputation: 6335

Because you haven't added $location to your array. Try this:

wikiControllers.controller('articleController', ['$scope', 'articleService', '$routeParams', '$sanitize', '$location', 
function($scope, articleService, $routeParams, $sanitize, $location){

$scope.deleteArticle = function(){
  //articleService.deleteArticle(this.article);
  $location.path("/hjem");
}
  }]);

Upvotes: 1

Related Questions