回到页面时我一直收到错误:
TypeError: Cannot read property 'charAt' of undefined
at Object.Pb.$$parse (chrome-extension://jiflmhpffanabaldnciipnblmfjcjado/bower_components/angular/angular.min.js:86:140)
at chrome-extension://jiflmhpffanabaldnciipnblmfjcjado/bower_components/angular/angular.min.js:90:313
at k.$eval (chrome-extension://jiflmhpffanabaldnciipnblmfjcjado/bower_components/angular/angular.min.js:111:353)
at k.$digest (chrome-extension://jiflmhpffanabaldnciipnblmfjcjado/bower_components/angular/angular.min.js:108:419)
at chrome-extension://jiflmhpffanabaldnciipnblmfjcjado/bower_components/angular/angular.min.js:90:426
at chrome-extension://jiflmhpffanabaldnciipnblmfjcjado/bower_components/angular/angular.min.js:38:222
at Array.forEach (native)
at q (chrome-extension://jiflmhpffanabaldnciipnblmfjcjado/bower_components/angular/angular.min.js:7:280)
at f (chrome-extension://jiflmhpffanabaldnciipnblmfjcjado/bower_components/angular/angular.min.js:38:205)
at chrome-extension://jiflmhpffanabaldnciipnblmfjcjado/bower_components/angular/angular.min.js:31:225
目前正在创建一个chrome扩展程序,其中angularjs嵌入到页面中。我的content.js文件:
'use strict';
window.addEventListener("load", function() {
if ( window.location.host.match(/(stack|gmail|shopify|magento|zendesk|desk.com|)/) ){
// load the app from all the other dependancies
var app = angular.module('joggle_ecommerce', [
"joggle_ecommerce.controllers",
"joggle_ecommerce.services",
"joggle_ecommerce.directives"
])
.config(function($locationProvider) {
// $locationProvider.html5Mode(true).hashPrefix('!');
})
// find the html and add the angular needed directives
var html = document.querySelector('html');
html.setAttribute('ng-app', '');
html.setAttribute('ng-csp', '');
// bootstrap due to angular needing to load after page load
angular.bootstrap(html, ['joggle_ecommerce'], []);
}
})
当我删除angular.bootstrap(html, ['joggle_ecommerce'], []);
时,这个问题不会持续存在,但据我所知,我需要在扩展名中加入bootstrap,因为在页面加载后需要加载角度。