Components that you use across multiple applications need to follow a module pattern that keeps them separate from your application logic. This will allow you to make these Angular 2 components reusable and shareable and is the same pattern followed…
定义 Angular CLI:The Angular CLI is a command line interface tool that can create a project, add files, and perform a variety of ongoing development tasks such as testing, bunding, and deployment. 总而言之,Angular CLI是一款功能很多的命令行工具. 环境 首先要安装Node.js和npm 然后使用…
angular回车键搜索,angular enter搜索 对于搜索框,用户在输入内容后的搜索习惯不是鼠标点击搜索按钮,而是直接按enter键,那我们怎么给enter键绑定事件呢,其实很简单,代码如下: 只用给input中添加 ng-keypress="($event.which === 13)?事件名:0" 举个例子 <input type="text" ng-model="productName" ng-keypress="($…
Angular 2 升级到 Angular 5 ts文件最上面的import语句里不要添加 .ts 后缀 , 不然 npm start 编译会失败 . 虽然浏览器能打开项目的URL , 但是内容会丢失. 举例 , 把 import { Article } from './article/article.model.ts'; 改成 import { Article } from './article/article.model'; 来自为知笔记(Wiz)…
In this lesson I demonstrate how to use the library MDXC to create and import React components with Markdown. MDXC converts markdown into JavaScript and supports JSX. Additional Resources: https://github.com/jamesknelson/mdxc   Create a React app by…
Angular程序架构 Angular程序架构 组件:一段带有业务逻辑和数据的Html服务:用来封装可重用的业务逻辑指令:允许你向Html元素添加自定义行为模块: 环境搭建 安装nodeJs安装好nodeJs后,在cmd中我们将可以使用npm(nodeJs 的包管理工具 ) 查看nodeJs版本 1 npm -v 安装angular cli命令行工具 1 npm install -g @angular/cli 查看angular cli 版本 1 ng -v 创建auction项目 12 ng…
Install: npm i -g angular-cli Create a project: ng new hello-angular2 Run the project: cd hello-angular2 ng serve Change the port: ng serve --port --live-reload-port Create a component: ng g component contact-list-component The component will be crea…
Simple Auth service: import { Injectable } from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {Observable} from 'rxjs/Observable'; import {User} from '../model/user'; import {BehaviorSubject} from 'rxjs/BehaviorSubject'; im…
You need to define a <template> to be able to use it elsewhere in your app as a TemplateRef. You can store these TemplateRefs in a Service and then access them from any @Directive or @Component in your app. We want to create a service and a componen…
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}…