zoukankan      html  css  js  c++  java
  • templating(模板)

    templating特点:

    Dynamic Loading动态加载

    Directives指令

    Component Directive组件指令示例:

    @ComponentDirective({
        selector:'tab-container',
        directives:[NgRepeat]
    })
    export class TabContainer {
        constructor(panes:Query<pane>) {
            this.panes = panes;
        }
    
        select(selectedpane:pane) { ... }
    }

    Decorator Directive装饰器指令示例:

    @DecoratorDirective({
        selector: '[ng-show]',
        bind:{'ngShow:': 'ngShow'},
        observe: {'ngShow': 'ngShowChanged'}
    })
    export class NgShow {
        constructor(element:Element) {
            this.element = element;
        }
    
        ngShowChanged(newValue){
            if(newValue){
                this.element.style.display = 'block';
            }else{
                this.element.style.display = 'none';
            }
        }
    }

    Template Directive模板指令示例:

    @TemplateDirective({
        selector: 'nf-if',
        bind: {'ngIf': 'nfIfChanged'}
    })
    export class NgIf {
        constructor(viewFactory:BoundviewFactory, viewport:ViewPort) {
            this.viewFactory = viewFactory;
            this.viewPort = viewPort;
            this.view = null;
        }
    
        ngIfChanged(value) {
            if (!value && this.view) {
                this.view.remove();
                this.view = null;
            }
            if (value) {
                this.view = this.viewFactory.createView();
                this.view.appendto(this.viewPort);
            }
        }
    }
  • 相关阅读:
    commonjs promise/A 规范
    Java之抽象类
    Java中多态的用法
    Java之方法的重写
    Java中static的用法
    java中this的用法
    Java概述
    二叉排序树的创建、插入、删除
    常用排序算法
    LeetCode小白菜笔记[2]:Reverse Integer
  • 原文地址:https://www.cnblogs.com/cjxhd/p/5152716.html
Copyright © 2011-2022 走看看