Angularjs encounters with the small pits and techniques summary _angularjs

Source: Internet
Author: User

1. Templateurl and routing to run under the Web server.

2. Use template Replace set to True, the template should also have a corresponding label, otherwise no data appears.

After 3.1.2 version, the Ngroute module is independent.

4. An empty controller does not define an error.

The link parameters for 5.Directive are sequential: Scope,element,attrs,ctrl

6.ng-repeat objects that cannot be recycled. Hack:ng-repeat= "thing in Things track by $id ($index)"

7. As far as possible update the properties of the variable rather than the individual variable itself.

8. Note that Ng-repeat,ng-controller can produce independent scopes.

9. When jquery is loaded, use jquery, otherwise the built-in jqlite is used. All element references in angular are always wrapped with jQuery or jqlite; They are never raw DOM references.

10.Uncaught Error: [$location: Ihshprfx] A label did not remove <a href= "#" ng-click= "SomeMethod ();" ></a>

11.error:listen eacces when in Linux, this error occurs because of the port you are listening to, here I am 33. Change it to a large number of ports such as 8080 or 3030. There is a rule that these ports are preferably greater than 1024.

The select cannot be displayed when there is no ng-model. Similarly, when you encounter an inability to display the best look at the document is less.

Complement: When the source of the ng-options, with the writing does not match the situation will appear when all the choices, as follows:

var a = [{"id": 1, "name": "Ryan"} ...], ng-options= "ITEM.I as Item.name for item in a"//I is different from ID

----------------------------------------------------------------------------------------

13.ng-bind-html-unsafe has been removed and can be used [' ngsanitize '] module or use $SCE service

From StackOverflow

You indicated ' re using angular 1.2.0 ... As one of the other comments indicated, Ng-bind-html-unsafe has been deprecated.

Instead, you'll want to do something like this:

Copy Code code as follows:
<div ng-bind-html= "Preview_data.preview.embed.htmlSafe" ></div>

In your controller, inject the $SCE service, and mark the HTML as "trusted":

Copy Code code as follows:
Myapp.controller (' Myctrl ', [' $scope ', ' $sce ', function ($scope, $SCE) {
// ...
$scope. Preview_data.preview.embed.htmlSafe =
$sce. trustashtml (preview_data.preview.embed.html);
}

This is the ' ll want to be using 1.2.0-RC3 or newer. (They fixed a bug in RC3 so prevented "watchers" from working to properly on trusted HTML.)

See more ANGULARJS syntax, you can pay attention to: Angularjs reference Manual in English, also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.