0

I'm serving an angular router in a drupal 7 page. The same example works fine in this fiddle: http://jsfiddle.net/laurencefass/Lsu8p124/.

HTML

<script type="text/ng-template" id="embedded.home.html">
  <h1> Home </h1>
</script>

<script type="text/ng-template" id="embedded.about.html">
  <h1> About </h1>
</script>

<div ng-app="routerApp"> 
  <div id="navigation">  
  <a href="#/home">Home</a>
  <a href="#/about">About</a>
  </div>
  <div ng-view></div>
</div>

Javascript

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

app.controller('HomeController', function ($scope) {});
app.controller('AboutController', function ($scope) {});
app.config(function ($routeProvider) {
    $routeProvider.
    when('/home', {
       templateUrl: "embedded.home.html",
       controller: 'HomeController'
    }).
    when('/about', {
       templateUrl: 'embedded.about.html',
       controller: 'AboutController'
    }).
    otherwise({
        redirectTo: '/home'
    });
});

I get the following runtime error:

"Error: [$compile:tpload] Failed to load template: embedded.home1.html (HTTP status: 404 Not Found) http://errors.angularjs.org/1.5.0-beta.1/$compile/tpload?p0=embedded.home1.html&p1=404&p2=Not%20Found minErr/<@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:68:5 handleError@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:17751:1 processQueue@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:14814:11 scheduleProcessQueue/<@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:14830:27 $RootScopeProvider/this.$gethttps://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:16058:9 $RootScopeProvider/this.$gethttps://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:15869:15 $RootScopeProvider/this.$gethttps://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:16166:13 done@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:10607:36 completeRequest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:10805:7 requestLoaded@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js?nwma5b:10750:1

1 Answer 1

0

The scripts need to be inside the ng-app div for inline scripts to work otherwise angular is looking for a file. not the best implementation, nor obviously documented, but it works for testing purposes. Using Inline Templates in Angular

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

Comments

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.