Angularjs templates in chrome extension

I am having a weird problem when using the angularjs template in an extended chrome extension of the contents of a script. I go in an endless loop. When I use the inline template (using the template attribute with a string), it works fine. Can anyone suggest what I'm doing wrong?

manifest.json

{
  "name": "Content Script Cross-Domain XMLHttpRequest Example",
  "version": "2.0.0",
  "manifest_version": 2,
  "description": "Demonstrates making cross domain requests from a content script by putting Twitter trends on Google News.",
  "permissions": [
    "http://localhost:9393/*"
  ],
  "icons": {
    "48" : "sample-48.png",
    "128" : "sample-128.png"
  },
  "content_scripts": [
    {
      "matches": ["http://news.google.com/*","*://mail.google.com/*"], 
      "js" : ["lib/jquery-1.6.4.min.js","lib/angular-1.0.1.min.js", "app.js","contentscript.js"]
    }
  ]
}

app.js

angular.module('myApp', []).
  config(['$routeProvider', function($routeProvider) {
  console.log('inside angular.module');
  $routeProvider.
      when('/', {templateUrl: 'contact.html',   controller: AppController}).
      otherwise({redirectTo: '/'});
}]);


function AppController($scope){
  console.log('inside AppController');
}

inside contentcript.js

$(this).append('<div id="gmeAppContainer">'
                                 + '<div ng-view></div>'
                              + '</div>');
var rootEle = $(this).find('#gmeAppContainer');
angular.bootstrap(rootEle,['myApp']);

When I use inline tempate in app.js, it works fine.

when('/', {template: '<div>This is inline template </div>',   controller: AppController}).

Also posted to google group angularjs https://groups.google.com/d/topic/angular/A_SVYZWPKe8/discussion

+5
source share
1 answer

Looks like I got it.

First declare the template file in the manifest.json file.

  "web_accessible_resources" :[
      "contact.html"
  ]

chrome.extension.getURL, URL-

  when('/', { controller: AppController, templateUrl : chrome.extension.getURL('contact.html')}).
+4

All Articles