The previous blog I have written about the development patterns of JavaScript large programs that I have been expecting, along with some advantages of TS (TypeScript). After the blog was completed, I spent another day experimenting with TS, which was used to reconstruct a JS game that I wrote before: "Javascript tank game." Source Download
Source I have been uploaded to the CSDN, no need for resources,: http://download.csdn.net/detail/zgynhqf
1. What is typescriptTypescript is a free and open source programming language developed by Microsoft. It is a superset of JavaScript and essentially adds optional static types and class-oriented object-oriented programming to the language. Typescript adds support for the features recommended for the upcoming ECMAScript 6 standard.Google's front-end framework angular is based on typescript development.
2.
'). Touched">{{signupform.get (' confirm '). Errors?. Confirmpassword.message}}span>
span*ngif= "signupform.get (' confirm '). Haserror (' required ') signupform.get (' Confirm '). Dirty">This field is requredspan>
Div>
Switch-control formcontrolname= "Newsletter"> Switch-control>
Div>
form> Here with the code we set the default value to being true thought "WriteValue" method handle by Angular2, also we get updated V Alue from t
In this tutorial we were going to learn what simple it was to create custom form field driven validators while using Angular 2 model driven forms. These type of validators is really just plain functions that follow a set of conventions.We is going to learn how to write a custom form validator and what the validating function needs to return with order to re SPECT the Angular 2 form field validation contract.Define a custom validator:Import {FormControl} from "@angular/forms"; export function val
ANGULAR2 Dependency injection contains too much content, one of the key points is the injector, and the injector is very difficult to understand, today we do not delve into the content of the injector, you can refer to the official documentation, we today to the level of the injector.That is, the container that gets the service for the component chooses which one is specific.Let's start with a background: There are 3 components appcomponent root compo
We can nest Formgorup: this. Reactiveform = fb.group ({ username: [ '], [ validators.required, validators.minlength (3) ] , pwds:fb.group ({ "' , "' }, {validator:passwordvalidator}) });We make password as an own group. So in HTML, we need to use formgroupname istead of Formcontrolname.form[Formgroup]= "Reactiveform"novalidate AutoComplete= "Off"> Divclass= "Form-field"> label>Username:label> inputFormcontro
| async"> a[Routerlink]= "Hero.id"routerlinkactive= "Active"[Routerlinkactiveoptions]= "{exact:true}">{{Hero.name}}a> Li> we can also do [routerlink]= "['/heros ', hero.id]", this would point to "HEROS/1"; If you do: [routerlink]= "[' heros ', hero.id]", this would point to "HEROS/HEROS/1" Since we is already in Heros MoD Ule We just need to does [routerlink]= "Hero.id", point to "HEROS/1 " -ul>Heros.component.ts:Import {Component, OnInit} from '@angular/core'; import {Starwarsservice} fro
Ngformcontrol-Binding an existing Control objectUnlike the ngcontrolname directive, Ngformcontrol binds an existing control/control object to a DOM element. You can use the Ngformcontrol directive when you need to initialize an input value .In the following code, using the Ngformcontrol directive to bind a DOM element to the member variable of the component Ezcomp movie, we need to create the control object first in the constructor :1 @View ({2 //to bind an INPUT element to a control object
// 2 seconds );For the first time, we have used this interface several times in our components:Src/app/app.component.tsHeroes:hero[]; Selectedhero:hero;Src/app/hero-detail.component.tsExport class Herodetailcomponent { Hero:hero;}So far, our service is even written!Using the serviceLet's test the service we've written in the component:Src/app/app.component.ts (partial code)Import {Heroservice} from './hero.service ';Src/app/app.component.ts (partial code)Providers: [Heroservice]Src/a
"Reactiveform"Novalidate autocomplete="off"> class="Form-field"> "title"> class="Field-error-message"*ngif="reactiveForm.controls.title.errors?. Required">Title isRequiredIn this tutorial we is going to learn how do we mark form fields in error and display error messages to the user of Angular 2 model driven forms. We'll see that the approach are similar than what do we do while using template driven forms, but in this case we don t hav E template exports available.We are going to see how the Fo
Angular 2 copy of a timesheet.js (JavaScript library for HTML5 CSS3 time sheets)Usage:NPM Install Ng2-timesheet--saveApp.component.tsImport Models and Componentimport {timesheetitem} from ' Ng2-timesheet/src/models/timesheet-item '; import {timesheet} From ' Ng2-timesheet/src/models/timesheet ', import {timesheetcomponent} from ' Ng2-timesheet/src/timesheet.component ' ; ...//Add Directive Reference directives: [Timesheetcomponent] ...//define data Model Timesheet = new Timesh 2002, [New Tim
Recently used Ionic2 to do a mall demo, respectively tested WAP, iOS and Android. Huawei's own browser and mobile phone QQ browser layout problem is more serious, packaged into iOS and Android app experience is relatively smooth, this write demo only made an HTTP request, the other is local test data, this situation performance can hardly see the difference with the native app. The following is a video of the real machine recorded with Huawei P9, you can experience the next.http://yuntv.letv.com
The data returned after a request with HTTP is updated, but the data for the bound page is not refreshed, and after finding it, it is found that the change detection changedetectorref can be used for detection refresh.Official Document Description: ChangedetectorrefThe application code is as follows:Import {component,ngmodule,changedetectorref, oninit}from ' @angular/core '; Constructor (Private CDR : Changedetectorref) {}getcommentitemsfunc () { this. Commentservice.getcommentitems(ID )
1. Description of the problem
In the absence of the lazy route to load, the first time when the load is particularly slow, affecting the user experience, ANGULAR2 can use Loadchildren lazy load, the first time to use only load the required modules, other modules in the real use of the time will go to load, When you open the browser console to view JS load, will find you in the use of the corresponding JS will be loaded, resulting in the first click on
Angular2 attribute-type directives
There are three types of directives in Angular:
1.components-directives with a template. Components-directives that have templates2.Structural Directives-change the DOM layout by adding and removing DOM elements. Structured directives-Instructions for changing the DOM layout by adding and removing DOM elements: 3.Attribute Directives-change the appearance or behavior of an element. Attribute-type directives-directiv
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.