[Angular 2] Create Angular 2 Porject with Angular CLI
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 created in src/app/contact-list-component.
// app.component.ts import { Component } from '@angular/core';
import {ContactListComponentComponent} from "./contact-list-component/contact-list-component.component"; @Component({
moduleId: module.id,
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
directives: [ContactListComponentComponent]
})
export class AppComponent {
title = 'app works!';
}
Generate a child component:
The child component should live inside parent component, for example, we create a contact-detail-component:
cd ./contact-list-component
ng g component ./contact-detail-component
//contact-iist-component.ts import { Component, OnInit } from '@angular/core';
import {ContactDetailComponentComponent} from "./contact-detail-component/contact-detail-component.component"; @Component({
moduleId: module.id,
directives: [ContactDetailComponentComponent],
selector: 'app-contact-list-component',
templateUrl: 'contact-list-component.component.html',
styleUrls: ['contact-list-component.component.css']
})
export class ContactListComponentComponent implements OnInit { constructor() {} ngOnInit() {
} }
If everything went well, you should see:
[Angular 2] Create Angular 2 Porject with Angular CLI的更多相关文章
- Angular 个人深究(一)【Angular中的Typescript 装饰器】
Angular 个人深究[Angular中的Typescript 装饰器] 最近进入一个新的前端项目,为了能够更好地了解Angular框架,想到要研究底层代码. 注:本人前端小白一枚,文章旨在记录自己 ...
- 从Java角度理解Angular之入门篇:npm, yarn, Angular CLI
本系列从Java程序员的角度,带大家理解前端Angular框架. 本文重点介绍Angular的开发.编译工具:npm, yarn, Angular CLI,它们就像Java在中的Maven,同时顺便介 ...
- (转载)从Java角度理解Angular之入门篇:npm, yarn, Angular CLI
本系列从Java程序员的角度,带大家理解前端Angular框架. 本文是入门篇.笔者认为亲自动手写代码做实验,是最有效最扎实的学习途径,而搭建开发环境是学习一门新技术最需要先学会的技能,是入门的前提. ...
- angular.module()创建、获取、注册angular中的模块
// 传递参数不止一个,代表新建模块;空数组代表该模块不依赖其他模块 var createModule = angular.module("myModule", []); // 只 ...
- [Angular 2] Create Shareable Angular 2 Components
Components that you use across multiple applications need to follow a module pattern that keeps them ...
- [Angular Directive] Create a Template Storage Service in Angular 2
You need to define a <template> to be able to use it elsewhere in your app as a TemplateRef. Y ...
- [Angular 2] Create template with Params
Angular 2 templates have a special let syntax that allows you to define and pass a context when they ...
- [Angular 2] Create a simple search Pipe
This lesson shows you how to create a component and pass its properties as it updates into a Pipe to ...
- [Angular 2] Order Dynamic Components Inside an Angular 2 ViewContainer
By default, when you generate components, they will simply be added to the page in order, one after ...
随机推荐
- Linux伙伴系统1
(一)--伙伴系统的概述 Linux内核内存管理的一项重要工作就是如何在频繁申请释放内存的情况下,避免碎片的产生.Linux采用伙伴系统解决外部碎片的问题,采用slab解决内部碎片的问题,在这里我们先 ...
- INCOIN Importing Multilingual Items (Doc ID 278126.1)
APPLIES TO: Oracle Inventory Management - Version: 11.5.9 to 11.5.10.CU2 - Release: 11.5 to 11.5 GOA ...
- Oracle系列之游标
涉及到表的处理请参看原表结构与数据 Oracle建表插数据等等 游标: 1.目的 解决“ select * ”返回空.多行记录问题 但凡select,就可能多行结果集,也就需要用游标 2.原理 多行 ...
- C++11 中的线程、锁和条件变量
转自:http://blog.jobbole.com/44409/ 线程 类std::thread代表一个可执行线程,使用时必须包含头文件<thread>.std::thread可以和普通 ...
- Using innodb_large_prefix to avoid ERROR #1071,Specified key was too long; max key length is 1000 bytes
Using innodb_large_prefix to avoid ERROR 1071 单列索引限制上面有提到单列索引限制767,起因是256×3-1.这个3是字符最大占用空间(ut ...
- hdu4666Hyperspace
http://acm.hdu.edu.cn/showproblem.php?pid=4666 先看一个求曼哈顿的帖子http://www.cnblogs.com/lmnx/articles/24797 ...
- ActiveX添加测试工程, 出现的问题[非选择性参数][找不到成员]
ActiveX 添加测试工程 1.新建工程MFC application, 2.添加完毕,在main Dialog中, 右键[Insert Activex Control],选择你的ActiveX控件 ...
- LVS与其他负载均衡软件的区别
有人在邮件列表问haproxy的作者为何haproxy无论是tcp模式还是http模式,能支撑的并发量都不是太大. Willy回答了这个问题. Exactly. The difference is ...
- java 产生随机数
package edu.sjtu.erplab.io; import java.util.Random; public class RandomTest { public static void ma ...
- 【CSS】Beginner5:Margins&Padding
1.Properties for spacing-out elements 外边距:A margin is the space space outside something 内边距:padding ...