import { Component } from '@angular/core';
import {AutoCompleteDirective} from "auto-complete";
import {AutoCompleteComponent} from "auto-complete";
@Component({
selector: 'my-app',
template: `
<h1> Autocomplete Directive Test - Local Source </h1>
component test with array of strings: {{arrayOfStrings | json}}<br/>
<input auto-complete
[(ngModel)]="model1"
[source]="arrayOfStrings"
placeholder="enter text"/>selected: {{model1 | json}}<br/><br/>
component test with array of id/values: {{arrayOfKeyValues | json}}<br/>
<input
auto-complete
[(ngModel)]="model2"
[source]="arrayOfKeyValues"
placeholder="enter text"/> selected: {{model2 | json}}<br/><br/>
component test with array of key/names: {{arrayOfKeyVaues2 | json}}<br/>
<input auto-complete [source]="arrayOfKeyValues2"
[(ngModel)]="model3"
placeholder="enter text"
value-property-name="key"
display-property-name="name"/>selected: {{model3 | json}}<br/><br/>
<h1> Autocomplete Directive Test - Remote Source </h1>
component test with remote source: {{googleGeoCode}}<br/>
<input auto-complete
[(ngModel)]="model4"
placeholder="Enter Address(min. 2 chars)"
[source]="googleGeoCode"
display-property-name="formatted_address"
path-to-data="results"
min-chars="2" />selected: {{model4 | json}}<br/><br/>
`,
directives: [AutoCompleteDirective, AutoCompleteComponent],
styles: [`
auto-complete, input {
display: block; border: 1px solid #ccc; width: 300px;
}
`]
})
export class AppComponent {
foo(event) {
alert(3134123421342134);
}
public arrayOfStrings: string[] =
["this", "is", "array", "of", "text"];
public arrayOfKeyValues: any[] =
[{id:1, value:'One'}, {id:2, value:'Two'}, {id:3, value:'Three'}, {id:4, value:'Four'}];
public arrayOfKeyValues2: any[] =
[{key:1, name:'Key One'}, {key:2, name:'Key Two'}, {key:3, name:'Key Three'}, {key:4, name:'Key Four'}];
public googleGeoCode: string = "https://maps.googleapis.com/maps/api/geocode/json?address=:keyword";
public model1;
public model2;
public model3;
public model4;
}
(function(global) {
var ngVer = '@2.0.0-rc.1'; // lock in the angular package version; do not let it float to current!
//map tells the System loader where to look for things
var map = {
'app': 'app',
'@angular': 'https://npmcdn.com/@angular', // sufficient if we didn't pin the version
'rxjs': 'https://npmcdn.com/rxjs@5.0.0-beta.6',
'ts': 'https://npmcdn.com/plugin-typescript@4.0.10/lib/plugin.js',
'typescript': 'https://npmcdn.com/typescript@1.8.10/lib/typescript.js',
};
//packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.ts', defaultExtension: 'ts' },
'rxjs': { defaultExtension: 'js' },
};
map['auto-complete'] = 'https://npmcdn.com/ng2-auto-complete@0.4.2';
packages['auto-complete'] = { main: 'dist/index.js', defaultExtension: 'js' }
var ngPackageNames = [
'common',
'compiler',
'core',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade',
];
// Add map entries for each angular package
// only because we're pinning the version with `ngVer`.
ngPackageNames.forEach(function(pkgName) {
map['@angular/'+pkgName] = 'https://npmcdn.com/@angular/' + pkgName + ngVer;
});
// Add package entries for angular packages
ngPackageNames.forEach(function(pkgName) {
// Bundled (~40 requests):
packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
// Individual files (~300 requests):
//packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
});
var config = {
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'ts',
typescriptOptions: {
tsconfig: true
},
meta: {
'typescript': {
"exports": "ts"
}
},
map: map,
packages: packages
}
System.config(config);
})(this);
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
<!DOCTYPE html>
<html>
<head>
<title>Angular 2 Tour of Heroes</title>
<!-- Polyfill(s) for older browsers -->
<script src="https://npmcdn.com/core-js/client/shim.min.js"></script>
<script src="https://npmcdn.com/zone.js@0.6.12?main=browser"></script>
<script src="https://npmcdn.com/reflect-metadata@0.1.3"></script>
<script src="https://npmcdn.com/systemjs@0.19.27/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
// Imports for loading & configuring the in-memory web api
import { provide } from '@angular/core';
// The usual bootstrapping imports
import { bootstrap } from '@angular/platform-browser-dynamic';
import { HTTP_PROVIDERS } from '@angular/http';
import { AppComponent } from './app.component';
bootstrap(AppComponent, [
HTTP_PROVIDERS
]);