Translate

25 Şubat 2016 Perşembe

TypeError: Cannot read property 'path' of undefined Angularjs

TypeError: Cannot read property 'path' of undefined in Angular.js


There was an error when I try to redirect to another page from controller
and I realize that my function has $location but my controller has not when I added firstly
to ListController . createData() function already has the $location inside of it


BEFORE
appControllers.controller('ListController', function($scope, $http, $timeout) {


  $scope.createData = function($scope, $location) {
  $location.path( "/test" );
//       $scope.activePath = $location.path('/test');
       console.log('createdata');
       };

});



After

appControllers.controller('ListController', function($scope, $http, $timeout ,$location) {

   $scope.createData = function() {
   $location.path( "/test" );
//        $scope.activePath = $location.path('/test');
         console.log('createdata');
       };

});



Have a nice coding

Hiç yorum yok:

Yorum Gönder

Bu Blogda Ara