1.在lib目录中添加 script.js 文件,并在index.html其他<script>之前引用之: <script src="lib/script.js"></script> 该文件来自 https://github.com/ded/script.js/blob/master/dist/script.js .   2.在app.js中增加全局函数LazyLoadTemplate()和LazyLoadJs(): function LazyLoa…
单页Web应用(SinglePage) 顾名思义,只使用一个页面的Web应用程序.单页面应用是指用户通过浏览器加载独立的HTML页面,Ajax加载数据页面无刷新,实现操作各种操作. 模板(template) 在AngularJS中,一个模板就是一个HTML文件.但是HTML的内容扩展了,包含了很多帮助你映射model到view的内容. »  HTML模板将会被浏览器解析到DOM中. »  DOM然后成为AngularJS编译器的输入. »  AngularJS将会遍历DOM模板来生成一些指导,即…
Before compilation? – Controller After compilation? – Link var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.name = 'First '; }); app.directive('exampleDirective', function() { return { restrict: 'E', templ…
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}…
Angular 2 allows you to pass values from inputs simply by referencing them in the template and passing them into your Subject.next() call. This lesson shows you how to make a number input and pass the value so you can configure how much you want the…
1.4 控制器:Controller ng 中的控制器用来对 scope 进行操作 包括初始化数据和定义事件响应函数等 ng 用来解耦业务逻辑层和视图层的关键 controller 操作 scope,View 则展现 scope 的内容 传统前端程序中大量复杂的 DOM 操作逻辑都被转变成对 scope 的操作 定义控制器的三种方式 定义控制器可以有三种方式,注意第一种已经被淘汰. 第一种:传统方式,使用全局函数定义控制器: function DemoCtrl($scope) { // code…
<!doctype html><html ng-app="HelloAngular"> <head> <meta charset="utf-8"> </head> <body> <div ng-controller="helloAngular"> <p>{{greeting.text}},angular-demo2</p> </div…
一个简单的例子,控制层:.controller('publishController',['$scope','publishService', function($scope,publishService){ publishService.getData().then( function(answer){ $scope.data = answer.data; console.info(answer); }, function(error){ $scope.error = error; } );…
Angular 1 provided a mechanism to place content from your template inside of another template called transclusion. This concept has been brought into Angular 2 and was renamed to content projection and given super powers. In this lesson learn how to…
Component: import { Component, Input, ChangeDetectionStrategy, EventEmitter, Output } from '@angular/core'; @Component({ selector: 'stock-counter', changeDetection: ChangeDetectionStrategy.OnPush, template: ` <div class="stock-counter"> &l…