Structural directives enable you to use an element as a template for creating additional elements. Creating structural directives requires a knowledge of <template> elements, but they're easy and extremely powerful once you undrestand the concepts.…
 Just like passing in an array to *ngFor, you can pass in any value into your structural directive so that it can render templates based on those values. It's crucial to understand how the *directive syntax expands into a <template> and adds a custo…
一.directive中的scope directive无疑是AngularJS中比较复杂难懂的部分,而directive中个scope更是其中最复杂的部分了,尤其是在嵌套directive中互相通讯的时候. 单独的directive中,scope概念还是比较简单的,此时scope的三种取值情况为: scope:false  此时,directive没有独立的scope对象,link函数中引用的scope对象来自于当前节点的默认controller scope:true  此时,directiv…
Just like in *ngFor, you're able to pass in data into your own structural directives. This is done by declaring the variable using a let statement then passing context into the createEmbeddedView call. We know *ngFor we did like this: *ngFor="let mes…
本系列从Java程序员的角度,带大家理解前端Angular框架. 本文重点介绍Angular的开发.编译工具:npm, yarn, Angular CLI,它们就像Java在中的Maven,同时顺便介绍一些Angular的概念.学习之后,希望你能够在自己的环境下练习.探索.编写出自己的第一个基于Angular的Web应用. 在开始介绍之前,先了解下一些背景知识,理解单页应用与传统基于模板的多页应用在Web开发思路的不同. 什么是单页应用(Single Page Application,SPA)单…
Angular 个人深究[Angular中的Typescript 装饰器] 最近进入一个新的前端项目,为了能够更好地了解Angular框架,想到要研究底层代码. 注:本人前端小白一枚,文章旨在记录自己的学习过程,如有大神发现错误,也请评论指正. Angular 中的装饰器 当安装好Angular后,打开 文件[/my-app/src/app/app.module.ts] 与文件 [/my-app/src/app/app.component.ts] //app.component.tsimport…
本系列从Java程序员的角度,带大家理解前端Angular框架. 本文是入门篇.笔者认为亲自动手写代码做实验,是最有效最扎实的学习途径,而搭建开发环境是学习一门新技术最需要先学会的技能,是入门的前提. 作为入门篇,本文重点介绍Angular的开发.编译工具:npm, yarn, Angular CLI,它们就像Java在中的Maven,同时顺便介绍一些Angular的概念.学习之后,希望你能够在自己的环境下练习.探索.编写出自己的第一个基于Angular的Web应用. 在开始介绍之前,先了解下一…
// 传递参数不止一个,代表新建模块;空数组代表该模块不依赖其他模块 var createModule = angular.module("myModule", []); // 只有一个参数(模块名),代表获取模块 // 如果模块不存在,angular框架会抛异常 var getModule = angular.module("myModule"); // true,都是同一个模块 alert(createModule == getModule); 该函数既可以创建…
前言: 最近一直在使用阿里的NG-ZORRO(Angular组件库)开发公司后端的管理系统,写了一段时间的Angular以后发现对于我们.NET后端开发而言真是非常的友善.因此这篇文章主要是对这段时间使用Angular做一些小总结,希望可以帮到有需要的同学. Angular学习前必备基础知识点: TypeScript基本常识: https://www.tslang.cn/docs/home.html Angular中文文档: https://angular.cn/docs GitHub地址: h…
For example we have two buttons: When we click nether one of those tow button, the modal should show up: We will use structure directive to do that. So create a new directive 'auModalOpenOnClick': import {Directive, TemplateRef, ViewContainerRef} fro…
原文: http://blog.thoughtram.io/angularjs/2015/01/02/exploring-angular-1.3-bindToController.html Angular1.2引入了新的语法 controllerAs, 它让scope更加清楚.干净, 让controller更加聪明. 在我们的Angular应用中使用controllerAs可以避免开发者经常遇到的一些问题. controllerAs 做为命名空间 让我们用代码说事,有两个controller如下…
<!DOCTYPE html> <html ng-app="MyApp"> <head> <title>Study 9</title> <script type="text/javascript" src="js/angular.js"></script> </head> <body> <div ng-controller="…
The post we have: http://www.cnblogs.com/Answer1215/p/4185504.html gives a breif introduce about bindToController on the directive. Here is a blog about bindToController from thoughtramwhich explains in detail why bingToController comes into handy an…
在angular中,Directive,自定义指令的学习,可以更好的理解angular指令的原理,当angular的指令不能满足你的需求的时候,嘿嘿,你就可以来看看这篇文章,自定义自己的指令,可以满足你的各种需求的指令. 本篇文章的参考来自  AngularJS权威指南 , 文章中主要介绍指令定义的选项配置 废话不多说,下面就直接上代码 //angular指令的定义,myDirective ,使用驼峰命名法 angular.module('myApp', []) .directive('myDi…
You can change behaviors of element and @Component properties based on services using @HostBinding in @Directives. This allows you to build @Directives which rely on services to change behavior without the @Component ever needing to know that the Ser…
1.2 指令:Directive AngularJS 通过被称为 指令 的新属性来扩展 HTML, 具体表现形式一般为带有前缀 ng-xxx 的 HTML 属性. 指令的使用形式 ng-xxx 的属性本身并不是标准中定义的属性 很多情况下无法通过语法校验 HTML5 允许扩展的属性,以 data- 开头 在 ng 中可以使用 data-ng- 作为前缀来让网页对 HTML5 有效 二者效果相同 内置指令 AngularJS 内置了很多指令,用来增强 HTML,以下是一些常用内置指令的介绍. ng…
自己正在做一个小网站,使用Angular JS + Express JS + Mongo DB,在开发过程中,遇到一些问题,所以整理出来.希望对大家都有帮助. 这是今天解决的一个问题,Angular JS抛出Warning: Tired to load angular more than once. 前端使用的就是Angular JS,同时前端脚本中我也使用了JQuery.以下是二者Script的最初调用顺序, 在public文件夹下的index.html中: <body ng-view> &…
If you're coming from AngularJS (v1.x) you probably remember the ng-true-value and ng-false-value directive which allowed to map custom boolean values like "yes" or "no" or whatever other value you had, onto your HTML form. In this les…
By default, when you generate components, they will simply be added to the page in order, one after another. Angular 2 provides methods on the ViewContainer that allow you to reorder components once they’ve been created and provide the order that you…
When you generate Angular 2 components, you’re still able to access the component instance to set properties and invoke methods from the component class. import {Component, ViewChild, ViewContainerRef, ComponentFactoryResolver, Input} from '@angular/…
https://angular.io/cli https://www.angular.cn/guide/quickstart https://ng.ant.design/docs/introduce/zh https://www.tutorialspoint.com/angular4/index.htm…
AngularJS 1.3 add $submitted for form, so you can use  $submitted  to track whether the submit event is trggered. Read More: https://egghead.io/lessons/angularjs-new-in-angular-1-3-updates-to-forms <!DOCTYPE html> <html> <head> <scrip…
视图部分: <div ng-app="myapp"> <div ng-controller="myctrl"> <p>{{name}}</p> <p>{{lastname}}</p> </div> </div> 控制器省略写法,揣测可能是为了学习方便,工程项目中建议写完整的代码,以免打包后$scope被替换掉. var app=angular.module("m…
In some cases your application might need to upload large amounts of data, such as files. Obviously for a good UX we should provide the user some feedback on the progress of the upload. Angular’s HttpRequest object has a property reportProgress which…
Besides sending (or requesting) the actual data to the server API, there’s also often the need to send further metadata that helps the server to correctly interpret our request. Such data is most often sent using HTTP headers. In this lesson we learn…
Compile time configuration options allow you to provide different kind of settings based on the environment you're building the Angular app for. You might for instance have a development, staging and production environment. With the Angular CLI you'r…
The upload class will be used in the service layer. Notice it has a constructor for file attribute, which has a type of File. This will allows us to initialize new uploads with a JavaScript File object. You will see why this is important in the next…
This post is based on the NG-CONF talk, check the talk by yourself. 1. Dynamiclly add Angular Element into your application: Once you have angular element, then inside your new application, you can use 'docuemnt.createElement' to add it: 2. Lazy load…
Based on the talk from NG-CONF. Check it out by yourself, here is just my own take away :) Differential loading: The basic idea is that, Angular will build tow version of Javascript bundle. One is ES5 version to support all browsers, another one is E…
第一步:安装 Angular CLI 你要使用 Angular CLI 来创建项目.创建应用和库代码,并执行多种开发任务,比如测试.打包和发布. 全局安装 Angular CLI. 要想使用 npm 来安装 CLI,请打开终端/控制台窗口,并输入下列命令: npm install -g @angular/cli 第二步:创建一个工作区和初始化应用 Angular 工作区 就是你开发应用的上下文环境. 每个工作区包含一些供一个或多个项目使用的文件. 每个项目都是一组由应用.库或端到端(e2e)测试…