<!DOCTYPE html>
<html>
<head>
<base href="." />
<script type="text/javascript" charset="utf-8">
window.AngularVersionForThisPlunker = 'latest'
</script>
<title>angular playground</title>
<link rel="stylesheet" href="style.css" />
<script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js/dist/zone.js"></script>
<script src="https://unpkg.com/zone.js/dist/long-stack-trace-zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script>
<script src="https://unpkg.com/systemjs@0.19.31/dist/system.js"></script>
<script src="config.js"></script> <link rel="stylesheet" href="//rawgit.com/MSakamaki/AdventCalendar2014/master/scripts/bower_components/angular-material/angular-material.css">
<script src="//rawgit.com/MSakamaki/AdventCalendar2014/master/scripts/bower_components/angular/angular.js"></script>
<script src="//rawgit.com/MSakamaki/AdventCalendar2014/master/scripts/bower_components/angular-aria/angular-aria.js"></script>
<script src="//rawgit.com/MSakamaki/AdventCalendar2014/master/scripts/bower_components/angular-animate/angular-animate.js"></script>
<script src="//rawgit.com/MSakamaki/AdventCalendar2014/master/scripts/bower_components/hammerjs/hammer.js"></script>
<script src="//rawgit.com/MSakamaki/AdventCalendar2014/master/scripts/bower_components/angular-material/angular-material.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
loading...
</my-app>
</body>
</html>
/* Styles go here */
### Angular Starter Plunker - Typescript
var angularVersion;
if(window.AngularVersionForThisPlunker === 'latest'){
angularVersion = ''; //picks up latest
}
else {
angularVersion = '@' + window.AngularVersionForThisPlunker;
}
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
paths: {
'npm:': 'https://unpkg.com/'
},
//map tells the System loader where to look for things
map: {
'app': './src',
'@angular/core': 'npm:@angular/core'+ angularVersion + '/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common' + angularVersion + '/bundles/common.umd.js',
'@angular/common/http': 'npm:@angular/common' + angularVersion + '/bundles/common-http.umd.js',
'@angular/compiler': 'npm:@angular/compiler' + angularVersion + '/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic' + angularVersion + '/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http' + angularVersion + '/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router' + angularVersion +'/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms' + angularVersion + '/bundles/forms.umd.js',
'@angular/animations': 'npm:@angular/animations' + angularVersion + '/bundles/animations.umd.js',
'@angular/platform-browser/animations': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser-animations.umd.js',
'@angular/animations/browser': 'npm:@angular/animations' + angularVersion + '/bundles/animations-browser.umd.js',
'@angular/material': 'npm:@angular/material' + angularVersion + '/bundles/material.umd.js',
'@angular/core/testing': 'npm:@angular/core' + angularVersion + '/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common' + angularVersion + '/bundles/common-testing.umd.js',
'@angular/common/http/testing': 'npm:@angular/common' + angularVersion + '/bundles/common-http-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler' + angularVersion + '/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic' + angularVersion + '/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http' + angularVersion + '/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router' + angularVersion + '/bundles/router-testing.umd.js',
'tslib': 'npm:tslib@1.6.1',
'rxjs': 'npm:rxjs',
'typescript': 'npm:typescript@2.2.1/lib/typescript.js'
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
}
}
});
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';
platformBrowserDynamic().bootstrapModule(AppModule)
//our root app component
import { Component, NgModule, VERSION } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ContentChild, ComponentFactoryResolver, ViewContainerRef, Directive, ComponentRef, ViewChild, TemplateRef, ElementRef, Renderer2, ReflectiveInjector, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
/* REPEATABLE ELEMENT */
@Directive({selector: '[mnItem]'})
export class MnItemDef {
constructor(private _viewContainer: ViewContainerRef, private templateRef: TemplateRef<any>) { }
@Input() mnItem : any;
ngOnInit() {
console.log(this.mnItem);
this._viewContainer.createEmbeddedView(this.templateRef, {$implicit:this.mnItem});
}
}
/* REPEATING WRAPPER */
@Component({
selector: 'mn-element',
template:'<div *mnItem="let item"><ng-container></ng-container></div>'
})
export class MnElementDef {
@Input() itemWidth;
@Input() item;
constructor() {}
ngOnInit(){
console.log(this.item);
}
}
/* CONTAINER COMPONENT */
@Component({
selector: 'mn-flex-cards',
templateUrl: './mn-flex-cards.component.html',
styleUrls: []
})
export class MnFlexCardsComponent implements OnInit {
@ViewChild('placeHolder', {read: ViewContainerRef}) private _placeHolder: ViewContainerRef;
@Input() items = [];
@Input() pageSize = 10;
@Input() mode = "memory";
@Input() itemWidth = "250px";
@Input() filter = true;
@Input() pager_top = true;
@Input() pager_bottom = true;
filter_string = "";
@Input() backend:BackendManagementService;
@Input() memoryItems = [];
@Input() itemSize = 0;
filtered = [];
pageIndex = 0;
constructor(private _cmpFctryRslvr: ComponentFactoryResolver) {
}
doGetPage(){
if (this.mode == "memory"){
this.items = this.filtered.slice(this.pageSize*this.pageIndex,this.pageSize*(this.pageIndex+1) )
}
for (let itm of this.items){
let cmp = this.createComponent(this._placeHolder, MnElementDef);
cmp.instance.itemWidth = this.itemWidth;
cmp.instance.item = itm;
this._placeHolder.insert(cmp.hostView);
}
}
ngOnInit() {
if(this.mode == "memory"){
this.itemSize = this.memoryItems.length;
this.filtered = this.memoryItems.slice(0,this.memoryItems.length);
}
this.doGetPage();
}
public createComponent (vCref: ViewContainerRef, type: any): ComponentRef<any> {
let factory = this._cmpFctryRslvr.resolveComponentFactory(type);
let injector = ReflectiveInjector.fromResolvedProviders([], vCref.parentInjector);
let comp = factory.create(injector);
return comp;
}
}
/* PAGE */
@Component({
selector: 'pages-points',
templateUrl: './pages-points.component.html',
styleUrls: ['./pages-points.component.css']
})
export class PagesPointsComponent implements OnInit {
constructor() { }
ngOnInit() {
}
search = "";
onKey(event: any) { // without type info
console.log(event.target);
//this.values += event.target.value + ' | ';
}
items = [{
"title":"Negozio 1",
"subtitle":"test",
"img":"/assets/icons/Associazione.png",
"descr":"Consegne il mercoledì<br>18:00-19:00",
"lon":"11.35",
"lat":"44.42",
},{
"title":"Negozio",
"subtitle":"test",
"img":"",
"descr":"Descrizione",
"lon":"11.31",
"lat":"44.41",
},{
"title":"Negozio",
"subtitle":"test",
"img":"",
"descr":"Descrizione",
"lon":"11.32",
"lat":"44.43",
},{
"title":"Negozio",
"subtitle":"test",
"img":"",
"descr":"Descrizione",
"lon":"11.33",
"lat":"44.44",
},{
"title":"Negozio",
"subtitle":"test",
"img":"",
"descr":"Descrizione",
"lon":"11.37",
"lat":"44.45",
},{
"title":"TES6",
"subtitle":"test",
"img":"",
"descr":"Descrizione",
"lon":"11.31",
"lat":"44.46",
}];
}
/* APPCOMPONENT */
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
}
/* ROUTER */
const appRoutes: Routes = [
{ path: '', component: PagesPointsComponent },
];
/* MODULE */
@NgModule({
declarations: [
AppComponent,
PagesPointsComponent,
MnFlexCardsComponent,
MnElementDef,
MnItemDef
],
imports: [
RouterModule.forRoot(
appRoutes,
{
useHash: true,
enableTracing: false // <-- debugging purposes only
}
),
],
exports: [],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
.dark-bg{
background-color: #28602B;
}
header{
text-align:center;
}
h1{
color:#43A047;
text-shadow: #999 2px 2px 4px ;
}
.half-container{
margin-left: auto;
margin-right:auto;
width:800px;
}
#filo_map{
margin-left:auto;
margin-right:auto;
width:400px;
height:300px;
}
<div class="dark-bg">
<div class="half-container">
<mn-flex-cards [memoryItems]="items" mode="memory" [filter]="false" [pager_top]="false" itemWidth="250px" backend="bms">
<mn-element >
<div style="margin:10px;" *mnItem="let item">
<h1>{{item.title}}</h1>
<p>{{item.description}}</p>
</div>
</mn-element>
</mn-flex-cards>
</div>
</div>
<router-outlet></router-outlet>
.pull-right{
float:right;
}
md-toolbar{
color:white;
}
footer{
bottom:0;
position:relative;
width:100%;
}
.top, .footer{
font-family: 'Pacifico', cursive;
}
.example-spacer {
flex: 1 1 auto;
}
.centered span{
margin-left:10px; margin-right:10px;
}
.smaller{
font-size:0.6em;
}
<div fxLayout='row' class="zero" fxLayoutAlign="space-around center" fxLayoutWrap fxLayoutAlign="center stretch">
<ng-template #placeHolder></ng-template>
</div>