Karan Tiwari
Karan Tiwari

Reputation: 83

$routeProvider is not able to access html template

I have added both the files of angular.min.js and angular-route.min.js but still not working

app.js code:

var myApp = angular.module('myApp',[
'ngRoute',
'artistControllers'
]);

myApp.config(['$routeProvider', function($routeProvider){
$routeProvider.
when('/list',{
    templateUrl:'partials/list.html',
    controller:'ListController'
}).
otherwise({
    redirectTo: '/list'
});
}]);

controller.js code:

var artistControllers = angular.module('artistControllers',[]);

artistControllers.controller('ListController', function($scope,$http){

$http.get('js/data.json').then(function(response){
    $scope.artist=response.data;
    $scope.artistOrder='name';
}); 
});

Upvotes: 1

Views: 328

Answers (2)

Mumin Korcan
Mumin Korcan

Reputation: 101

I think the problem is that you did not include your controller.js to your html

<script src="controller.js"></script>

look at this plnkr https://plnkr.co/edit/eH6PtL?p=preview

Upvotes: 1

Surinder Batti
Surinder Batti

Reputation: 109

Hope this will be help for you.

Remove 'artistControllers' from array:

angular.module('myApp', ['ngRoute','artistControllers']);

try this one

from angular.module('myApp', ['ngRoute']);

and check you file path for partials/list.html from the root of your application.

Upvotes: 1

Related Questions