0

I'm getting the following error when I want to click on a link to show a single template (item):

WARNING: Tried to load angular more than once.

Link to screenshot: https://i.stack.imgur.com/OylSJ.png

Here is my templates.html code:

<div ng-repeat="template in filteredTemplates | filter:q" class="col-lg-4 col-md-6 col-sm-6 col-xs-12 portfolio-item">
  <h4>
      <a href="/edit/{{template.id}}" class="template-name"  >{{ template.name }} </a>
  </h4>
  <p>{{ template.content.substring(0, 40) | htmlToPlaintext | removeNbsp }} ...</p> 
  <div class="row">
      <div class="col-lg-6">
          <div ng-repeat="license in template.licenses">{{license.name}} prijs <i class="fa fa-eur" aria-hidden="true"></i> {{license | setPrice}}</div>
      </div>                                        
      <div class="col-lg-6">
          <a ng-click="placeOrder(template)"  class="btn btn-info" role="button"> Add to cart <span class="fa fa-cart-plus"></span></a>
      </div>
  </div>
</div>

app.js code:

//This will handle all of our routing
app.config(function($routeProvider, $locationProvider){
    $routeProvider.when('/', {
        templateUrl: 'js/templates/home.html',
        controller: 'HomeController'
    });

    $routeProvider.when('/templates', {
        templateUrl: 'js/store/templates.html',
        controller: 'TemplateController'
    });

    $routeProvider.when('/edit/:id', {
        templateUrl: 'js/store/template.html',
        controller: 'GetTemplateController'
    });

    $locationProvider.html5Mode({
        enabled: true,
        requireBase: false
    });
});

templateController.js:

template.controller('GetTemplateController', function ($scope, $routeParams, Template) {
      console.log('here');
});

I suspect that the problem comes from the app.js file. Does someone knows what I'm doing wrong? Because I really can't figure it out

Claies
  • 22,124
  • 4
  • 53
  • 77
superkytoz
  • 1,267
  • 4
  • 23
  • 43
  • The error you are seeing is most likely being caused because you have `ng-app` listed in the `template.html` file. That is only a guess, however, since you haven't shown the contents of that file. – Claies Jun 18 '16 at 17:59
  • @Claies Here is the content of template.html link: http://i.imgur.com/Mrcr6Sg.png my ng-app is in welcome.blade.php (I'm using Laravel). Here is the content of welcome.blade.php link: http://pastebin.com/1jCy8KkY – superkytoz Jun 18 '16 at 18:36

1 Answers1

0

Taken from here:

You'll notice that if the app can't find a file (i.e., otherwise), then it will redirect to the root, which in this case loads the templateUrl. But if your templateUrl is wrong, then it will cause a recursion that reloads index.html loading angular (and everything else) over and over.

Seems like wrong template url is what's causing this.

Community
  • 1
  • 1
Muli Yulzary
  • 2,559
  • 3
  • 21
  • 39
  • I understand but the file template.html should be found link to screenshot: http://i.imgur.com/T0NpDWc.png As you can see I have a template.html file in the store folder. – superkytoz Jun 18 '16 at 18:42
  • The other thing I can think of is that the angular script tag is present twice. – Muli Yulzary Jun 19 '16 at 07:58
  • That's also not the case in my welcome.blade.php file link: http://pastebin.com/1jCy8KkY There you can see I have only present the angular script once.. – superkytoz Jun 19 '16 at 09:58