Skip to content

Commit 9977676

Browse files
author
tanggc
committed
add:Init files
1 parent bce848a commit 9977676

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1420
-2
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2015-2016 Google, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
# angular2-contacts-demo
2-
Angular 2 (ng2) 通讯录例子
1+
### Usage
2+
- Clone or fork this repository
3+
- Make sure you have [node.js](https://nodejs.org/) installed
4+
- run `npm install -g webpack webpack-dev-server typings typescript` to install global dependencies
5+
- run `npm install` to install dependencies
6+
- run `npm start` to fire up dev server
7+
- open browser to [`http://localhost:3000`](http://localhost:3000)

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "contact",
3+
"version": "1.0.0",
4+
"description": "A simple starter Angular2 project",
5+
"scripts": {
6+
"typings-install": "node node_modules/typings/dist/bin.js install",
7+
"postinstall": "npm run typings-install",
8+
"build": "node node_modules/webpack/bin/webpack.js --inline --colors --progress --display-error-details --display-cached",
9+
"watch": "npm run build -- --watch",
10+
"server": "node node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --colors --progress --display-error-details --display-cached --port 3000 --content-base src",
11+
"start": "npm run server"
12+
},
13+
"license": "MIT",
14+
"devDependencies": {
15+
"awesome-typescript-loader": "~0.16.2",
16+
"source-map-loader": "^0.1.5",
17+
"typescript": "~1.8.9",
18+
"typings": "^0.7.9",
19+
"webpack": "^1.12.9",
20+
"webpack-dev-server": "^1.14.0",
21+
"webpack-merge": "^0.8.4"
22+
},
23+
"dependencies": {
24+
"@angular/common": "2.0.0",
25+
"@angular/compiler": "2.0.0",
26+
"@angular/core": "2.0.0",
27+
"@angular/forms": "2.0.0",
28+
"@angular/http": "2.0.0",
29+
"@angular/platform-browser": "2.0.0",
30+
"@angular/platform-browser-dynamic": "2.0.0",
31+
"@angular/router": "3.0.0",
32+
"@angular/upgrade": "2.0.0",
33+
34+
"core-js": "^2.4.1",
35+
"reflect-metadata": "^0.1.3",
36+
"rxjs": "5.0.0-beta.12",
37+
"zone.js": "^0.6.23",
38+
"angular2-in-memory-web-api": "0.0.20",
39+
"bootstrap": "^3.3.6"
40+
}
41+
}

src/app.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
2+
import {AppModule} from './app/router/app-module';
3+
4+
platformBrowserDynamic().bootstrapModule(AppModule)
5+
.catch(err => console.error(err));
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
h3.collection-header{
2+
height: 35px;
3+
line-height: 35px;
4+
font-size: 16px;
5+
color: #ffffff;
6+
text-align: center;
7+
background-color: #3DD689;
8+
}
9+
h3.no-collection{
10+
position: absolute;
11+
top: 40%;
12+
left: 50%;
13+
transform: translate(-50%,-50%);
14+
font-size: 18px;
15+
}
16+
h3.collection-header{
17+
text-align: center;
18+
font-size: 16px;
19+
color: #ffffff;
20+
line-height: 35px;
21+
background-color: #3DD689;
22+
}
23+
.my-collection{
24+
position: absolute;
25+
top: 35px;
26+
left: 0;
27+
right: 0;
28+
bottom: 40px;
29+
padding: 0 15px;
30+
overflow: scroll;
31+
}
32+
.my-collection li{
33+
height: 50px;
34+
border-bottom: 1px solid #E0E0E0;
35+
}
36+
.my-collection li a{
37+
line-height: 30px;
38+
display: block;
39+
padding-top: 20px;
40+
text-decoration: none;
41+
}
42+
.my-collection li a label{
43+
width: 75px;
44+
font-size: 16px;
45+
color: #000000;
46+
display: inline-block;
47+
}
48+
.my-collection li a span{
49+
font-size: 16px;
50+
color: #000000;
51+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<h3 class="collection-header">我的收藏</h3>
2+
<h3 *ngIf="coll_length == 0" class="no-collection">没有收藏</h3>
3+
<ul class="my-collection">
4+
<li *ngFor="let collection of collections">
5+
<a [routerLink]="['/contact-detail', collection.id]">
6+
<label>{{ collection.name }}</label><span>{{ collection.telNum }}</span>
7+
</a>
8+
</li>
9+
</ul>
10+
<my-footer></my-footer>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {Component, OnInit} from '@angular/core';
2+
import {Footer} from '../../widget/footer';
3+
import {ContactService} from '../../services/contact-service';
4+
5+
@Component({
6+
selector: 'call-record',
7+
templateUrl: 'app/components/collection/collection.html',
8+
styleUrls: ['app/components/collection/collection.css']
9+
})
10+
export class Collection implements OnInit {
11+
collections:any = [];
12+
contacts:any = {};
13+
14+
constructor(private _constactService: ContactService) { }
15+
16+
getCollectionContact() {
17+
let ss_contacts = sessionStorage.getItem('contacts');
18+
if(ss_contacts) {
19+
this.contacts = JSON.parse(ss_contacts);
20+
for(let i=0;i<this.contacts.length; i++){
21+
if(this.contacts[i].collection == 1){
22+
this.collections.push(this.contacts[i]);
23+
}
24+
}
25+
}else {
26+
this._constactService.getCollections().subscribe(data => {
27+
this.collections = data;
28+
})
29+
}
30+
}
31+
32+
ngOnInit() {
33+
this.getCollectionContact();
34+
}
35+
}

src/app/components/contact-app.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.main{
2+
width: 100%;
3+
height: 100%;
4+
background-color: #fafafa;
5+
}
6+

src/app/components/contact-app.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<main class="main">
2+
<router-outlet></router-outlet>
3+
</main>

src/app/components/contact-app.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {Component} from "@angular/core";
2+
3+
@Component({
4+
selector: "contact-app",
5+
templateUrl: "./app/components/contact-app.html",
6+
styleUrls: ["./app/components/contact-app.css"]
7+
})
8+
9+
export class ContactApp {
10+
constructor() {}
11+
}

0 commit comments

Comments
 (0)