One, the creation of instructions/*--js code--*/var app = Angular.module ("Superhero", []);app.directive ("Superman", function () {return {Restrict: "E",Template: "}})/*--html code--*/div ng-app="Superhero" > superman>superman>div> This allows you to create a single instruction.two, restrictions on instructionsRestrict: "A", Indicates that the directive is for "attribute (attribute)",Restrict: "E", which indicates that the
The previous article spoke of the communication between the directive and the controller, but what about the communication between US Directive and directive?When we use two directive nested, how to ensure that the child directive will not be replaced by the parent
1. Custom directivesIn angular, the directive method below the module is used to create custom directives, using:M1.directive (' Mytab ', function () {return {Restrict: ' AE ',Replace:true,Templateurl: ",};});For general usage, return an object in the second argument of directive, which has various properties.Restrict-
the value of the hero. name attribute of the component in the element.[Hero] property binding: transfers the value of the parent component to the hero attribute of the Child component.(Click) event binding: Call A method when a user clicks an element.
The relationships between files need to be sorted out clearly.Two-way data binding: both property binding and event binding are supported. Example:
// app/hero-detail.component.ts
The value of the data property is transmitted from the component wi
The use of controller is divided into two situations, one is require custom controller, because the property method in custom controller is written by oneself, it is simpler to be used, and the other method is require ANGULARJS built-in instruction , most of the time it takes require to ngmodel this instruction.When customizing the angular directive, there is a field called require, which is used to communi
, the role of the directive is to replace our custom semantic tags with HTML tags that browsers can recognize . Well, if there's a child tag inside our custom tag, how do we handle it? It is clear that transclude is used to deal with this situation.
For the current example, the role of transclude can be easily understood as: replace the remain unchanged.
Obviously, since we don't have the replace:true option, the
You can add replace:true to the JS
of the parent class (the concept is also described below)
Service
Service can be understood as the M layer in the MVC structure, to deal with the specific business logic, the most ideal code is to trigger the controller in the view of the function, and then the controller to invoke the model inside the specific processing, The model then returns the data to the controller to change the scope, which is reflected on the view. Service is the function, in a
Original source: https://my.oschina.net/blogshi/blog/280400
Absrtact: Voluminous wrote a lot of the recent construction projects of some experience, for the construction of angular project is really not in harmony with the previous front-end framework, so it is hereby recorded to share to everyone, and hope to be helpful.
Objective
Contact Angular also has a small half month, although not hard to toss, but
Original addressWe talked about transclude, so we're going to go on with the following.9.scopeOptional parameter, the default value is False. Value:False-The new scope is not created in this directive, but the scope of the parent is inherited.True-Creates a new scope for this directive and inherits the scope of its parent.{}-object, create a new, isolated scope in this
value of priority is assumed to be 0.Scope (in this case, it is worth mentioning the $scope object, as well as the difference between using the $scope and this in the controller (which can be used when using controller as in HTML), and searching by itself if interested)It has a value of three kinds; True,false (default), object.What is scope in angular?Scope(http://code.angularjs.org/1.0.2/docs/api/ng. $rootScope. Scope) is an object that points to t
The angular team recently released the official version of angular 1.5, which implemented a major upgrade that still uses 1. The X-version developer will be able to easily transition to angular 2 development.
"The purpose of this release is to" improve the angular 2 upgrade path, "Pete Bacon Darwin wrote in a blog pos
With regard to the naming of custom directives, you can do whatever name you like, officially it is recommended to use [namespace-directive name] in such a way as Ng-controller. However, you must not use the ng-prefix, to prevent the same name as the system comes with the instructions. Another place to know, the command named with the hump rules, use-split the words. Such as: Define mydirective, use like this:The legal naming of
Introduction: angular-smarty, angular JS tool that can automatically complete the UI
This article mainly introduces angular-smarty, an AngularJS tool that can automatically complete the UI, including the use of the isolation scope binding directive and promise. For more information, see
We recently added an Automatic
Vue. directive () usage and instance details, vue. directive details
Official Website instance:
Https://cn.vuejs.org/v2/api/#Vue-directive
Https://cn.vuejs.org/v2/guide/custom-directive.html
The instruction definition function provides several hook functions (optional ):
Bind: it is called only once. It is called when the command is bound to an element for the fi
(i) use static include directives(ii) Use of dynamic include directivespageencoding= "Iso-8859-1"%>The scriptlet.jsp page code is as follows:Out.write ("from scriptlet.jsp");%>(c) The difference between static and dynamic imports:(1) Static import is the code that is imported into the page completely into, two pages into a whole servlet, so the imported page does not even need to be a full page, and dynamic import in the servlet using the Include method to introduce the content of the imported p
strings oh, you can not put properties ohThere is a situation where we pass in the property name, and in the link function we use the $parse (attr) (scope) to get the value, which is not ideal, because it can only be run without isolating scope.Whether to use isolation scope, I personally do not have a special idea, as long as you carefully use it.I personally prefer to use isolation.Isolate the difference between scope "=", "@", ""Isolation scope puts the value of the attr into the scope of th
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.