angularjsng-viewroute-providerangularjs-ng-routeng-controller

$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';
}); 
});

Solution

  • 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