Input handling is an important part of application development. The ng-model directive provided in Angular 1 is a great way to manage input, but we think we can do better. The new Angular Forms module is easier to use and reason about than ng-model,…
https://www.pluralsight.com/guides/angular-event-binding Introduction In this guide, we will explore on the topic of event binding in Angular. Event binding will help to build interactive web applications with the flow of data from component to the e…
如果想在某个属性发生变化的时候执行某些操作,那么scope.$watch是最佳选择 https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$watch //如果是中文... $rootScope.$watch('session', function() { if ($rootScope.session) { var re = /[\u4e00-\u9fa5]/; if (re.test($rootScope.session.last_na…
https://daveceddia.com/access-control-allow-origin-cors-errors-in-angular/ Getting this error in your Angular app? No ‘Access-Control-Allow-Origin’ header is present on the requested resource. You’ve run afoul of the Same Origin Policy – it says that…
Angular 2’s ngModel provides error objects for each of the built-in input validators. You can access these errors from a reference to the ngModel itself then build useful messaging around them to display to your users. First, you can use 'ngModel' fr…
Idea is set up javascript as an api, then just change html to control the behavor. var app = angular.module("app", ["ngAnimate"]); app.controller("AppCtrl", function() { this.isHidden = false; this.isLarged = false; this.idR…
Orgial aritial --> Link The problem with Angular 1 DI: Angular 2 DI: Solve the singletons problem: The service you inject to the parent component can be differnet with the one you inject to child component: var injector = ReflectiveInjector.resolveAn…
When you implement a search bar, the user can make several different queries in a row. With a Promise based implementation, the displayed result would be what the longest promise returns. This is the problem which we want to solve. <!DOCTYPE html> &…
When you create a Form in Angular 2, you can easily get all the values from the Form using ControlGroup and Controls. Bind [ng-form-model] to the <form> form bind to ControlGoup Bind [ng-form-control] to the <input> input bind to Gontrol impor…
This lessons implements the Search Pipe with a new SearchBox component so you can search through each todo. It also demonstrates the patterns used for components to interact with each other. Often generic components are used for handling user input t…
Link: Blog Single transclude: <ng-content></ng-content> Multi-translcude: <ng-content select=".label"></ng-content> <ng-content select=".title"></ng-content>…