我们通过一个NgModule来启动一个ng app,NgModule通过bootstrap配置来指定应用的入口组件. @NgModule({ bootstrap: [ AppComponent ], .... } 在 declarations 可以配置sub_component declarations: [ FriendsComponent, ChatsComponent ] 如下构造一个TestComponent: import { Component, OnInit, Input, OnC…
更新 2018-02-07 详细讲一下 TemplateRef 和 ViewContainerRef 的插入 refer : https://segmentfault.com/a/1190000008672478 https://stackoverflow.com/questions/45438304/insert-a-dynamic-component-as-child-of-a-container-in-the-dom-angular2 https://stackoverflow.com/q…
Error: ELOOP: too many symbolic links encountered, stat 'C:\Users\inn\angulardemo\node_modules\@angular\cli\node_modules\webpack\node_modules\escope\node_modules\es6-map\node_modules\d\node_modules\es5-ext\node_modules\es6-iterator\node_modules\d\nod…
在基于Angualr的SPA中,路由是一个很重要的部分,它帮助我们更方便的实现页面上区域的内容的动态加载,不同tab的切换,同时及时更新浏览器地址栏的URN,使浏览器回退和前进能导航到历史访问的页面. (1) 基本配置 1.1.配置base href 在配置RoutesModule之前,我们需要再index.html里配置base href,这样,每一个路由的路径的前缀都是base href,应用的图片,文件夹,样式等资源都通过该base href来定位. //index.html<base h…
我们在上篇介绍了 @track / @api的区别.在父子 component中,针对api类型的变量,如果声明以后就只允许在parent修改,son component修改便会导致报错. sonItem.html <template> <lightning-input value={itemName} onchange={changeItemName} label="item name"></lightning-input> </templa…
在Angular2 模板中,我们在显示数据时,可以使用通道将数据转换成相应的格式的值的形式来显示,而且这不改变源数据.比如,我们可以使用date通道来转换时间显示的格式: {{date | date:'yyyy-MM-dd'}} ,(1) 以下是Angular提供的基本的通道. Basic Pipes Pipe Name Usage Parameters or Effection currency {{test.currency | currency }} 1234569678 > USD1,2…
本文转自:https://stackoverflow.com/questions/35570746/angular2-including-thirdparty-js-scripts-in-component/35570783#35570783 Script tags in component templates are removed. A workaround is to create the script tag dynamically in ngAfterViewInit() See al…
We have a render prop based class component that allows us to make a GraphQL request with a given query string and variables and uses a GitHub graphql client that is in React context to make the request. Let's refactor this to a function component th…
//switch-control component import { Component } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, Validators} from '@angular/forms'; @Component({ selector: 'switch-control', templateUrl: './switch-control.componen…
Learn how to use the 'lifecycle' higher-order component to conveniently use hooks without using a class component. import React from 'react'; import { withReducer, withHandlers, compose, lifecycle } from 'recompose'; // Mock Configuration function fe…