HJB77 HJB77 - 7 months ago 12
HTML Question

Angular JS - View not working

Evening,

I am struggling to integrate view into my code,was wondering if someone could please help me troubleshoot. I've exhausted the little i do know.

I've got it working offline without views (controller in the index.html) and it looks like this

Local Example

Here is the plunk version of what I couldn't get working locally

http://plnkr.co/edit/f7XVqxnVzDjGd17a4SMB?p=preview

It has something to do with my HomeController.js file because it is currently redirecting via "otherwise" in app.js as without it nothing shows

app.js

var app = angular.module("DraftApp", ['ngRoute']);

app.config(function ($routeProvider) {
$routeProvider
.when('/players', {
controller: "HomeController",
templateUrl: "main.html"
})
.otherwise({
redirectTo: '/players'
});
});


HomeController

app.controller("HomeController", ["$scope", "players",
function($scope, players) {
players.success(function(data) {
$scope.players = data;
});
$scope.filters = {};
$scope.predicate = 'PTS';
$scope.reverse = true;
$scope.order = function(predicate) {
$scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : true;
$scope.predicate = predicate;
};
}
]);`

Answer

There is a spelling mistake, so the controller is not getting laoded,

Change,

From

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

To

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

Working Applciation