


(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

AI Hentai Generator
Generate AI Hentai for free.

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



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

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