zoukankan      html  css  js  c++  java
  • Angular(2)

    在angular中使用双向数据绑定需要引入相关的模块,并且在组件中配置好

    angular也有和vuex类似的服务,名为services,通过ng g s servicename创建服务

    angular可以用自带的ViewChild操作DOM,先引入ViewChild:

                                ①.给模板中的dom起一个名字,<div #myBox></div>

                                ②.在业务逻辑里面引入ViewChild , import { Component, OnInit ,ViewChild} from '@angular/core';

                                ③.写在类里面 @ViewChild('myBox')myBox:any;

                                ④.ngAfterViewInit生命周期函数里面获取dom,使用方法:this.myBox.nativeElement

  • 相关阅读:
    elastic
    原生js获取css样式和修改css样式
    React项目开发中的数据管理
    js获取鼠标位置
    闭包
    HTML5与HTML4的区别
    JSON 相关
    RESTful Web Services初探
    IE6浏览器兼容问题及部分解决方案
    关于Doctype
  • 原文地址:https://www.cnblogs.com/ttaoai/p/13343315.html
Copyright © 2011-2022 走看看