I'm having an issue with Angular scope, specifically where I can't get the data to be injected into my view. I understand that the ng-repeat creates it's own scope, as well as ng-view, but for whatever reason, the first div in my view (loops.html - #main-content-wrapper) is also creating it's own scope. Why?
EDIT: Is it possible that routes are not working - i.e. that the Loops controller isn't being attached to ng-view?
App.js:
'use strict';
angular.module('testApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute'
])
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
templateUrl: 'views/loops.html',
controller: 'LoopCtrl'
})
.when('/live', {
templateUrl: 'views/live.html',
controller: 'LoopCtrl'
})
.when('/inputs', {
templateUrl: 'views/inputs.html',
controller: 'LoopCtrl'
})
.when('/menu', {
templateUrl: 'views/menu.html',
controller: 'LoopCtrl'
})
.otherwise({
redirectTo: '/'
});
}]);
/controllers/loops.js:
(function (angular) {
'use strict';
angular.module('testApp')
.controller('LoopCtrl', ['$scope', '$http', function ($scope, $http) {
$http.get('loops.json').success(function(data) {
$scope.loops = data;
});
}]);
}(this.angular));
views/loops.html:
<div id="main-content-wrapper">
<div id="main-content">
<article>
<header>
<h1>Select your loop channel</h1>
</header>
<div ng-repeat="loop in loops">
<h1>{{loops.title}}</h1>
<span>{{loops.duration}}</span>
</div>
</article>
</div>
</div>
index.html (relevant part):
<body ng-app="testApp">
<div id="container" ng-view>
</div>
</body>
first div in view creates own scope. A demo in plunker would help