import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {MovieComponent } from './movie/movie.component';
@NgModule({
declarations: [
AppComponent,
MovieComponent
],
imports: [
BrowserModule
],
providers: [ ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
import { Component } from '@angular/core';
import { Movie } from './movie';
@Component({
selector: 'app-multiplication',
templateUrl: './movie.component.html',
styleUrls: ['./movie.component.css']
})
export class MovieComponent{
selectedMovie=null;
sourceMovieList:Array<Movie> =new Array<Movie>();
movieList:Array<Movie> =new Array<Movie>();
movieJsonList= [{
"id": 1,
"movie_name": "Coraline",
"price": "7.13",
"movie_date": "7/9/2017"
}, {
"id": 2,
"movie_name": "Finding Dory",
"price": "10.09",
"movie_date": "12/12/2016"
}, {
"id": 3,
"movie_name": "The Wailing",
"price": "10.69",
"movie_date": "3/9/2017"
}, {
"id": 4,
"movie_name": "The Void",
"price": "8.85",
"movie_date": "10/30/2017"
}, {
"id": 5,
"movie_name": "Tower",
"price": "8.47",
"movie_date": "4/6/2017"
}];
constructor(){
for(let i=0;i<this.movieJsonList.length;i++){
this.sourceMovieList[i]=new Movie();
Object.assign( this.sourceMovieList[i],this.movieJsonList[i]);
}
this.movieList=this.sourceMovieList;
}
less=(x:Movie):boolean=>{return x.price<9};
more=(x:Movie):boolean=>{return x.price>9};
filterMovies(funcParam:any){
this.movieList=this.sourceMovieList.filter(funcParam);
}
selectItem(movie:any) :void{
this.selectedMovie=movie;
}
}
.list-type1 {
width: 400px;
margin: 0 auto;
}
.list-type1 ol {
counter-reset: li;
list-style: none;
*list-style: decimal;
font-size: 15px;
font-family: 'Raleway', sans-serif;
padding: 0;
margin-bottom: 4em;
}
.cont, .list-type1 ol ol {
margin: 0 0 0 2em;
}
.cont, .list-type1 a {
position: relative;
display: block;
padding: .4em .4em .4em 2em;
*padding: .4em;
margin: .5em 0;
background: #93C775;
color: #000;
text-decoration: none;
-moz-border-radius: .3em;
-webkit-border-radius: .3em;
border-radius: 10em;
transition: all .2s ease-in-out;
}
.cont, .list-type1 a:hover {
background: #d6d4d4;
text-decoration: none;
transform: scale(1.1);
}
.list-type1 a:before {
content: counter(li);
counter-increment: li;
position: absolute;
left: -1.3em;
top: 50%;
margin-top: -1.3em;
background: #93C775;
height: 2em;
width: 2em;
line-height: 2em;
border: .3em solid #fff;
text-align: center;
font-weight: bold;
-moz-border-radius: 2em;
-webkit-border-radius: 2em;
border-radius: 2em;
color: #FFF;
}
.heading{padding-left:100px}
td {
padding: 10px;
}
table {
margin-top: 20px;
margin-bottom: 20px;
text-align: center;
}
.info-movie {
padding-left: 75px;
font-size: medium;
border-radius: 10px;
padding-top: 30px;
padding-bottom: 30px;
}
<div class="list-type1">
<button class="cont" (click)="filterMovies(more)">
more than $9
</button>
<button class="cont" (click)="filterMovies(less)">
less than $9
</button>
<h1 class="cont heading">
movie list
</h1>
</div>
<div class="list-type1">
<ol>
<li *ngFor="let movie of movieList"><a href="#" (click)="selectItem(movie)">
{{movie.movie_name}}</a>
</li>
</ol>
</div>
<div class="list-type1" *ngIf="selectedMovie">
<div class="cont info-movie">
<p>
<b>selected movie: </b> {{selectedMovie.movie_name}}
</p>
<table border="1">
<thead>
<tr>
<td>
Country:
</td>
<td>
price:
</td>
<td>
Date:
</td>
</tr>
</thead>
<tr>
<td>
USA
</td>
<td>
{{selectedMovie.price|currency:'USD':true}}
</td>
<td>
{{selectedMovie.movie_date}}
</td>
</tr>
<tr>
<td>
IL
</td>
<td>
{{selectedMovie.price*4|currency: 'ILS': true}}
</td>
<td>
{{selectedMovie.movie_date}}
</td>
</tr>
</table>
</div>
</div>
<app-multiplication></app-multiplication>
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
/* Master Styles */
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 250%;
padding-left:30px;
}
body {
margin: 2em;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Tour of Heroes</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="stylesheet" href="styles.css" />
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<app-root></app-root>
</body>
</html>
/**
* WEB ANGULAR VERSION
* (based on systemjs.config.js in angular.io)
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'ts',
typescriptOptions: {
// Copy of compiler options in standard tsconfig.json
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
meta: {
'typescript': {
"exports": "ts"
}
},
paths: {
// paths serve as alias
'npm:': 'https://unpkg.com/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
'app': 'app',
// angular bundles
'@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
'@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
// other libraries
'rxjs': 'npm:rxjs@5.5.2',
'rxjs/operators': 'npm:rxjs@5.5.2/operators/index.js',
'tslib': 'npm:tslib/tslib.js',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api@0.4/bundles/in-memory-web-api.umd.js',
'ts': 'npm:plugin-typescript@5.2.7/lib/plugin.js',
'typescript': 'npm:typescript@2.4.2/lib/typescript.js',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts',
meta: {
'./*.ts': {
loader: 'systemjs-angular-loader.js'
}
}
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
var templateUrlRegex = /templateUrl\s*:(\s*['"`](.*?)['"`]\s*)/gm;
var stylesRegex = /styleUrls *:(\s*\[[^\]]*?\])/g;
var stringRegex = /(['`"])((?:[^\\]\\\1|.)*?)\1/g;
module.exports.translate = function(load){
if (load.source.indexOf('moduleId') != -1) return load;
var url = document.createElement('a');
url.href = load.address;
var basePathParts = url.pathname.split('/');
basePathParts.pop();
var basePath = basePathParts.join('/');
var baseHref = document.createElement('a');
baseHref.href = this.baseURL;
baseHref = baseHref.pathname;
if (!baseHref.startsWith('/base/')) { // it is not karma
basePath = basePath.replace(baseHref, '');
}
load.source = load.source
.replace(templateUrlRegex, function(match, quote, url){
var resolvedUrl = url;
if (url.startsWith('.')) {
resolvedUrl = basePath + url.substr(1);
}
return 'templateUrl: "' + resolvedUrl + '"';
})
.replace(stylesRegex, function(match, relativeUrls) {
var urls = [];
while ((match = stringRegex.exec(relativeUrls)) !== null) {
if (match[2].startsWith('.')) {
urls.push('"' + basePath + match[2].substr(1) + '"');
} else {
urls.push('"' + match[2] + '"');
}
}
return "styleUrls: [" + urls.join(', ') + "]";
});
return load;
};
export class Movie{
id:number;
movie_name:string;
price:number;
movie_date:any;
print():string{
return "proof that I am in a class";
}
}