


(10) Reasons and solutions for the failure of the ng-inlude directive to load the page_html/css_WEB-ITnose
The ng-include directive provided in angularjs is very similar to the
The parent page parent.html code is as follows:
<html> <head> <script src="angular-1.2.2/angular.js"></script> <script> function rootController($scope,$rootScope,$injector) { $rootScope.name = "aty"; $rootScope.age = 25; } </script> </head> <body ng-app ng-controller="rootController"> <h1>Hello, {{name}}!</h1> <h1>Hello, {{age}}!</h1> <div id="included" ng-include="'child.html'"> <input type="button" value="2"/> </div> </body></html>
The included child page child.html code is as follows:
<div> <h1>included, {{name}}!</h1> <h1>included, {{age}}!</h1> </div>
I use IE11 and Chrome39 runs parent.html and finds that the child.html page cannot be included in parent.html. The error message reported under IE is as follows:
Error: 拒绝访问。 at Anonymous function (file:///D:/learn/angular-1.2.2/angular.js:7852:7) at sendReq (file:///D:/learn/angular-1.2.2/angular.js:7720:9) at serverRequest (file:///D:/learn/angular-1.2.2/angular.js:7454:9)
The error message reported under chrome is as follows:
XMLHttpRequest cannot load file:///D:/learn/include.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///D:/learn/include.html'.
The prompt under IE is a bit obscure, but the chrome prompt is obvious: cross-domain access is not allowed . From the above error message, you can see that when using the ng-include directive, AJAX request XMLHttpRequest will be used. However, we opened parent.html directly with the browser and did not access it through the web container, so there was a cross-domain access problem, and loading child.html failed. The solution is simple: deploy the code to a web container such as tomcat and access it through http.
When I usually practice javascript or JS framework, I use relatively lightweight tools. I don’t use IDEs like Eclipse. I usually use Notepad writes js code. Notepad can easily call the browser installed on the machine. Instructions like ng-include must be supported by the web container. You can use the front-end development artifact webstorm. When this tool runs HTML, it will automatically start the built-in web container, so that the ng-include instruction will not report an error.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...
