0

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;
    };
  }
]);`

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Sajeetharan, two mistakes 1. was the one you found 2. other was <tr class="each" ng-repeat="player in players | filter:filters | orderBy:predicate:reverse"> to <tr class="each" ng-repeat="player in myplayers | filter:filters | orderBy:predicate:reverse">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.