Angualr 1.4: .directive('counter', function counter() { return { scope: {}, restrict: 'EA', transclude: true, bindToController: { count: '=' }, controller: function () { function increment() { this.count++; } function decrement() { this.count--; } th…
Angular 1.5 introduced the .component() helper method, which is much simpler than the.directive() definition and advocates best practices and common default behaviours. Using .component() will allow developers to write in an Angular 2 style as well,…
When migrating AngularJS (v1.x) applications to Angular you have different options. Using Angular Elements is one of them. In this lesson we learn how to integrate an Angular Element into an AngularJS (v1.x) application. We will leverage some feature…
原版地址:http://docs.angularjs.org/guide/dev_guide.mvc.understanding_model 在angular文档讨论的上下文中,术语“model”可以适用于单一对象代表一个实体(例如,一个叫” phones”的model,它的值是一个电话数组.)或者作为应用的全部数据Model(所有实体). 在angular中,model可以是任意数据,可以通过angular的scope对象的属性来获取model.属性的名称是model的标识,值可以是任意jav…
原版地址:http://docs.angularjs.org/guide/dev_guide.mvc.understanding_model 在angular中,controller是一个javascript 函数(type/class),被用作扩展除了root scope在外的angular scope(http://www.cnblogs.com/lcllao/archive/2012/09/23/2698651.html)的实例.当我们或者angular通过scope.$new API(h…
[js类库AngularJs]解决angular+springmvc的post提交问题 AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前端JS框架,已经被用于Google的多款产品当中.AngularJS有着诸多特性,最为核心的 是:MVVM.模块化.自动化双向数据绑定.语义化标签.依赖注入.等等. 参考资料: angularjs中文网:http://www.apjs.net/ angularjs官网:http://angularj…
With Angular scopes, you have access to a $destroy event that can be used to watch $scope events. This is used for cleanup, and gives you a final opportunity to access any data on a scope. Scopes also have a (rarely used) $destroy method that allows…
Traditionally you had to create DOM elements to test a directive but by shifting our focus to components, writing unit tests got a lot easier using $componentControllerwithin ngMocks. We can now test our component's controller with an easy to use API…
With the ocLazyLoad you can load AngularJS modules on demand. This is very handy for runtime loading of Angular modules in large applications. Simple example: angular.module("demo", ["oc.lazyLoad"]) .controller("AppCtrl", fun…
By default, Angular provides a lot of debug information on the DOM that's only necessary for tools like Protractor and Batarang. Angular 1.3 allows you to turn off the debug information to give your app a simple performance boost. See: https://docs.a…
<!DOCTYPE html> <html ng-app="MyApplication"> <head> <link rel="stylesheet" href="style.css"> <script src="https://code.angularjs.org/1.5.0-beta.2/angular.js"></script> <script…
Angular实现下拉菜单多选 写这篇文章时,引用文章地址如下: http://ngmodules.org/modules/angularjs-dropdown-multiselect http://dotansimha.github.io/angularjs-dropdown-multiselect/#/ AngularJS Dropdown Multiselect This directive gives you a Bootstrap Dropdown with the power of …
ANGULAR.JS: NG-SELECT AND NG-OPTIONS PS:其实看英文文档比看中文文档更容易理解,前提是你的英语基础还可以.英文文档对于知识点讲述简明扼要,通俗易懂,而有些中文文档读起来特别费力,基础差.底子薄的有可能一会就会被绕晕了,最起码英文文档中的代码与中文文档中的代码是一致的,但知识点讲述实在是差距太大. Angular.js has a powerful directive waiting for you: it's ng-select. With it you c…
The main idea for testing contianer component is to make sure it setup everythings correctlly. Call the onInit() lifecycle first, then the variables have the right value. Methods will be called with the right params. Container component: import { Com…
报错现象: 用modal打开某个组件页面时报错 报错:No component factory found for UpdateAuthWindowComponent. Did you add it to @NgModule.entryComponents? 原因: 使用loadChild模式加载对应路由下的组件时,是懒加载模式,即需要的时候才会加载,所以如果路由走的是懒加载模式,需要的module即使在app.module中引入过了,依旧需要再引入一次 解决方案: 在app.module 的e…
1. 组件Component示例 2. Component常用的几个选项 3. Component全部的选项 3.1 继承自@Directive装饰器的选项 3.2 @Component自己特有的选项 4. 自定义component 1. 组件Component示例 组件是由一个装饰器@Component来声明的,继承自@Directive import {Component} from '@angular/core'; @Component({ selector: 'app-root233',…
If you want to use controllers, instead of a link function, you can use bindToController. <!DOCTYPE html> <html ng-app="app"> <head> <title>Egghead.io Tutorials</title> <style>body{padding:20px}</style>…
Showing you how you can expose properties on your Controller to access them using #refs inside of your template. // letterSelect.ts import {Component, View, FORM_DIRECTIVES, NgFor} from 'angular2/angular2'; @Component({ selector: 'letter-select' }) @…
Download from npm:https://www.npmjs.com/package/angular-md-table +: Responsive: Has both Mobile view and Desktop view i18n: works well with angular-translate library Pagination: Has built-in pagination template Easy to use, one tag only for all basic…
addClass()-为每个匹配的元素添加指定的样式类名 after()-在匹配元素集合中的每个元素后面插入参数所指定的内容,作为其兄弟节点 append()-在每个匹配元素里面的末尾处插入参数内容attr() - 获取匹配的元素集合中的第一个元素的属性的值bind() - 为一个元素绑定一个事件处理程序children() - 获得匹配元素集合中每个元素的子元素,选择器选择性筛选clone()-创建一个匹配的元素集合的深度拷贝副本contents()-获得匹配元素集合中每个元素的子元素,包括文…
描叙:使用ng-class实现每隔3行换色 代码: <!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="UTF-8"> <title>隔行换色</title> <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.j…
方法一(使用指令) 1.指令(angular-ui-switch.js) angular.module('uiSwitch', []) app.directive('switch', function(){ return { restrict: 'AE' , replace: true , transclude: true , template: function(element, attrs) { var html = ''; html += '<span'; html += ' class=…
方法一:需要引入jq,否则会报angularJS1 Error: [jqLite:nosel](不建议使用) <div id="testID" class="test1"> <img id="testID2" class="test2" alt="" src="some-image.gif" /> </div> JS: angular.element(…
When use 'require', recommend to add some error check, for example: class ChildCtrl { constructor(){ // Get prop from parent ctrl if(this.parentCtrl){ this.childProp = this.parentCtrl.prop; } } } app.directive('someDirective', () => { return { requir…
Read fromhttps://medium.com/@bluepnume/sane-scalable-angular-apps-are-tricky-but-not-impossible-lessons-learned-from-paypal-checkout-c5320558d4ef ng-Controller is bad, use directive instead. Don't specfiy controller in Route, use directive in templat…
实现目标:不可复制页面内容 js: <script language="javascript"> if (typeof(document.onselectstart) != "undefined") { // IE下禁止元素被选取 document.onselectstart = function (event){ if(event.target.tagName!="INPUT"){ return false; } } } else…
demo: <ion-view view-title="{{chat.name}}"> <style type="text/css"> .image-loader-container{ height: 40px; position: absolute; top: 50%; margin-top: -13px; left: 18px; } </style> <ion-content class="padding&qu…
常用方法 滚动到顶部:$ionicScrollDelegate.scrollTop();或者$ionicScrollDelegate.$getByHandle('视图句柄').scrollTop(); 滚动到该视图的位置:$ionicScrollDelegate.$getByHandle('视图句柄').getScrollPosition(); 相关资料 http://www.ionic.wang/js_doc-index-id-30.html…
Component https://docs.angularjs.org/guide/component component本质上就是directive. This is a shorthand for registering a special type of directive, which represents a self-contained UI component in your application. Such components are always isolated (i.…
原版地址:http://docs.angularjs.org/guide/dev_guide.mvc.understanding_model angular template是一个声明规范,与model.controller的信息一起,渲染成用户在浏览器中所看到的视图.它是静态的DOM,包括HTML.CSS.angular特别的元素和angular指定的元素属性.angular元素和属性指示angular去扩展行为以及将template DOM转换为动态视图的DOM. 下面是我们可以在templ…