AngularJS Templates run twice
Posted
by
Curt
on Stack Overflow
See other posts from Stack Overflow
or by Curt
Published on 2012-12-03T01:13:52Z
Indexed on
2012/12/04
17:05 UTC
Read the original article
Hit count: 178
I'm working on an AngularJS web app with Twitter Bootstrap. The templates run twice. I don't know why they do this.
Below is some of the code in the index.html file:
<html data-ng-app="app" ng-controller="AppCtrl">
<div class="container ng-view" data-ng-view></div>
...
<script>
(function (angular) {
"use strict"; // jshint ;_;
// http://coenraets.org/blog/2012/02/sample-application-with-angular-js/
angular.module('app', ['filters', 'angular', 'currency'])
.config(function($routeProvider) {
var _view_ = 'view/';
$routeProvider.
when('/app', {templateUrl:_view_+'app/index.html', }).
when('/account/settings', {templateUrl:_view_+'app/settings.html', }).
when('/profile/:profile_ID', {templateUrl:_view_+'app/profile.html', controller:ProfilePageCtrl}).
when('/discuss', {templateUrl:_view_+'discuss/discuss.html', controller:DiscussCtrl}).
when('/', {templateUrl:_view_+'page/home.html' }).
when('/:page', {templateUrl:_view_+'page.html', controller:PageCtrl}).
otherwise({redirectTo:'/'});
})
...
Can anybody provide suggestions? Are the templates supposed to run twice?
2012-12-04 Update: I found out that the templates are running twice, not the controller.
© Stack Overflow or respective owner