使用下面提到的Code1在角度Js中进行基本路由并获得“
XMLHttpRequest无法加载交叉源请求仅支持协议方案:http,数据,chrome扩展,https,chrome-extension-resource”错误并且我们必须使用本地Web服务器解析相同的和下载的MAMP并保持我的html [login.html]在htdocs文件夹中启动服务器并用Code2中提到的[localhostURL / AngularJs / login.html’]替换templateUrl并获得错误错误:[ $sce:insecurl]下面给出了确切的错误,指导我在Google Chrome中修复相同的任何解决方案…
代码1
的index.html
<!DOCTYPE html> <html> <head> <title>Test</title> </head> <body ng-app="plunker"> <div ng-view=""></div> <script src="angular.min.js"></script> <script src="angular-route.js"></script> <script src="app.js"></script> </body> </html>
app.js
var app = angular.module('plunker',['ngRoute']); app.config(function ($routeProvider) { $routeProvider.when('/login',{ controller: '',templateUrl: 'login.html' }).otherwise({ redirectTo: '/login' }); });
的login.html
Hello from login!
码2
所有其他事情都与app.js中的更改相同
var app = angular.module('plunker',['ngRoute']); app.config(function ($routeProvider) { $routeProvider.when('/login',templateUrl: 'http://localhost:8888/AngularJs/login.html' }).otherwise({ redirectTo: '/login' }); });
错误代码1: –
XMLHttpRequest无法加载file:// localhost / Users / karthicklove / Documents / Aptana Studio 3 Workspace / Object_Javascript / Angular_Js / Routing / login.html.交叉源请求仅支持协议方案:http,chrome-extension-resource.
错误代码2: – [$sce:insecurl] http://errors.angularjs.org/1.2.26/ $sce / insecurl?p0 = http:// localhost:8888 / AngularJs / login.html出错(本机)