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应用. 在开始介绍之前,先了解下一些背景知识,理解单页应用与传统基于模板的多页应用在Web开发思路的不同. 什么是单页应用(Single Page Application,SPA)单…
本系列从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); 该函数既可以创建…
Install: npm i -g angular-cli Create a project: ng new hello-angular2 Run the project: cd hello-angular2 ng serve Change the port: ng serve --port --live-reload-port Create a component: ng g component contact-list-component The component will be crea…
Components that you use across multiple applications need to follow a module pattern that keeps them separate from your application logic. This will allow you to make these Angular 2 components reusable and shareable and is the same pattern followed…
You need to define a <template> to be able to use it elsewhere in your app as a TemplateRef. You can store these TemplateRefs in a Service and then access them from any @Directive or @Component in your app. We want to create a service and a componen…
Angular 2 templates have a special let syntax that allows you to define and pass a context when they’re being generated. import {Component, ViewChild, ViewContainerRef, ComponentFactoryResolver, ViewChild} from '@angular/core'; import {SimpleService}…
This lesson shows you how to create a component and pass its properties as it updates into a Pipe to make a simple searchable list. import {Pipe} from 'angular2/angular2'; @Pipe({ name: 'simpleSearch' }) export class SimpleSearch{ transform(value, [f…
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…
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…
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…
自己正在做一个小网站,使用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> &…
视图部分: <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…
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.…
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…
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…
Also check: directive for form validation User input validation is a core part of creating proper HTML forms. Form validators not only help you to get better quality data but they also guide the user through your form. Angular comes with a series of…
User input validation is a core part of creating proper HTML forms. Form validators not only help you to get better quality data but they also guide the user through your form. Angular comes with a series of built-in validators such as required or ma…
依赖注入是一个在组件中给出的替代了硬的组件内的编码它们的依赖关系的软件设计模式.这减轻一个组成部分,从定位的依赖,依赖配置.这有助于使组件可重用,维护和测试. AngularJS提供了一个至高无上的依赖注入机制.它提供了一个可注入彼此依赖下列核心组件. 值 工厂 服务 提供者 常值 值 值是简单的JavaScript对象,它是用来将值传递过程中的配置相位控制器. //define a module var mainApp = angular.module("mainApp", []);…
内容来自:http://www.runoob.com/angularjs/angularjs-intro.html AngularJS 是一个 JavaScript 框架.它是一个以 JavaScript 编写的库. 我们建议把脚本放在 <body> 元素的底部.这会提高网页加载速度,因为 HTML 加载不受制于脚本加载. AngularJS 通过 ng-directives 扩展了 HTML. ng-app 指令定义一个 AngularJS 应用程序. ng-model 指令把元素值(比如输…
在开始介绍angular原理之前,我们有必要先了解下mvvm模式在angular中运用.虽然在angular社区一直将angular统称为前端MVC框架,同时angular团队也称它为MVW(Whatever)框架,但angular框架整体上更接近MVVM模式.下面是Igor Minar发布在Google+ https://plus.google.com/+IgorMinar/posts/DRUAkZmXjNV的文章内容: MVC vs MVVM vs MVP. What a controver…
昨天晚上写完angular源码分析:angular中jqLite的实现--你可以丢掉jQuery了,给今天定了一个题angular源码分析:injector.js文件,以及angular的加载流程,但是想了想,加载流程还是放到后面统一再讲比较好. 如果你没有看过笔者的angular源码分析:angular中的依赖注入式如何实现的,可以点击看看,在其中讲过的内容,我将不会再这里重复,这一期将作那一期的补充. 一.从createInjector函数开始 先省去具体实现,总体看看:函数拥有两个参数,m…
angular的工具函数 在angular的API文档中,在最前面就是讲的就是angular的工具函数,下面列出来 angular.bind //用户将函数和对象绑定在一起,返回一个新的函数 angular.bootstrap //angular启动函数,一般不用,除了e2e测试 angular.copy //对象拷贝 angular.element //jQlite,作用类似于jQuery angular.equals //对象比较.用 == 对两个对象进行比较,除非他们是同一个对象的引用,否…