Skip to content

Angular2 Beta support #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/angular
Submodule angular updated 745 files
10 changes: 5 additions & 5 deletions ng-sample/app/benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {StackLayout} from 'ui/layouts/stack-layout';
import {Button} from 'ui/button';
import {Label} from 'ui/label';
import {Inject, Component, View, NgIf, NgFor} from 'angular2/angular2';
import {Inject, Component, View} from 'angular2/core';
import {ApplicationRef} from 'angular2/src/core/application_ref';
import * as profiling from './profiling';

@Component({selector: 'tree', inputs: ['data']})
@View({
directives: [TreeComponent, NgIf],
directives: [TreeComponent],
template:
`<StackLayout>
<Label [text]="data.value"></Label>
<StackLayout *ng-if="data.right != null">
<StackLayout *ngIf="data.right != null">
<tree [data]='data.right'></tree>
</StackLayout>
<StackLayout *ng-if="data.left != null">
<StackLayout *ngIf="data.left != null">
<tree [data]='data.left'></tree>
</StackLayout>
</StackLayout>
Expand All @@ -28,7 +28,7 @@ class TreeComponent {
selector: 'benchmark',
})
@View({
directives: [NgIf, NgFor, TreeComponent],
directives: [TreeComponent],
template: `
<StackLayout>
<Label text='Benchmark!' fontSize='20' verticalAlignment='center' padding='20'></Label>
Expand Down
16 changes: 7 additions & 9 deletions ng-sample/app/renderer-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Inject, Component, View, NgIf, NgFor} from 'angular2/angular2';
import {Inject, Component, View} from 'angular2/core';

@Component({
selector: 'templated-component',
Expand All @@ -8,10 +8,8 @@ export class TemplatedComponent {
}

@Component({
selector: 'renderer-test'
})
@View({
directives: [NgIf, NgFor, TemplatedComponent],
selector: 'renderer-test',
directives: [TemplatedComponent],
template: `
<TabView>
<TabView.items>
Expand All @@ -23,10 +21,10 @@ export class TemplatedComponent {
<TextField #name text='John' fontSize='20' padding='20'></TextField>
<Button [text]='buttonText' (tap)='onSave($event, name.text, $el)'></Button>
<Button text='Toggle details' (tap)='onToggleDetails()'></Button>
<TextView *ng-if='showDetails' [text]='detailsText'></TextView>
<TextView *ngIf='showDetails' [text]='detailsText'></TextView>
<Label text='==============================' fontSize='20'></Label>
<StackLayout #more *ng-if='showDetails' orientation='vertical'>
<TextField *ng-for='#detailLine of detailLines' [text]='detailLine'></TextField>
<StackLayout #more *ngIf='showDetails' orientation='vertical'>
<TextField *ngFor='#detailLine of detailLines' [text]='detailLine'></TextField>
</StackLayout>
<Label text='==============================' fontSize='20'></Label>
</StackLayout>
Expand Down Expand Up @@ -56,7 +54,7 @@ export class RendererTest {
this.moreDetailsText = 'More details:';

this.detailLines = [
"ng-for inside a ng-if",
"ngFor inside a ngIf",
"Street address",
"Country, city",
];
Expand Down
100 changes: 50 additions & 50 deletions ng-sample/package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
{
"name": "tns-template-hello-world",
"main": "app.js",
"version": "1.1.0",
"author": "Telerik <[email protected]>",
"description": "Nativescript hello-world project template",
"license": "BSD",
"keywords": [
"telerik",
"mobile",
"nativescript",
"{N}",
"tns",
"appbuilder",
"template"
],
"repository": {
"type": "git",
"url": "git://github.com/NativeScript/template-hello-world.git"
},
"bugs": {
"url": "https://github.com/NativeScript/template-hello-world/issues"
},
"homepage": "https://github.com/NativeScript/template-hello-world",
"dependencies": {
"@reactivex/rxjs": "5.0.0-alpha.7",
"parse5": "1.4.2",
"punycode": "1.3.2",
"querystring": "0.2.0",
"url": "0.10.3",
"reflect-metadata": "0.1.2",
"zone.js": "0.5.8"
},
"devDependencies": {
"grunt": "0.4.5",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-copy": "0.8.0",
"grunt-shell": "1.1.2",
"grunt-ts": "5.0.0-beta.5",
"nativescript-dev-typescript": "^0.2.2",
"shelljs": "^0.5.3",
"typescript": "^1.7.3",
"webpack": "^1.12.9"
},
"nativescript": {
"id": "org.nativescript.ngsample",
"tns-android": {
"version": "1.5.0"
}
}
}
"name": "tns-template-hello-world",
"main": "app.js",
"version": "1.1.0",
"author": "Telerik <[email protected]>",
"description": "Nativescript hello-world project template",
"license": "BSD",
"keywords": [
"telerik",
"mobile",
"nativescript",
"{N}",
"tns",
"appbuilder",
"template"
],
"repository": {
"type": "git",
"url": "git://github.com/NativeScript/template-hello-world.git"
},
"bugs": {
"url": "https://github.com/NativeScript/template-hello-world/issues"
},
"homepage": "https://github.com/NativeScript/template-hello-world",
"dependencies": {
"parse5": "1.4.2",
"punycode": "1.3.2",
"querystring": "0.2.0",
"url": "0.10.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
"devDependencies": {
"grunt": "0.4.5",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-copy": "0.8.0",
"grunt-shell": "1.1.2",
"grunt-ts": "5.0.0-beta.5",
"nativescript-dev-typescript": "^0.2.2",
"shelljs": "^0.5.3",
"typescript": "^1.7.5",
"webpack": "^1.12.9"
},
"nativescript": {
"id": "org.nativescript.ngsample",
"tns-android": {
"version": "1.5.1"
}
}
}
74 changes: 37 additions & 37 deletions ng-sample/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
{
"compilerOptions": {
"outDir": "app",
"rootDir": "app",
"module": "commonjs",
"target": "es5",
"inlineSourceMap": true,
"experimentalDecorators": true,
"removeComments": false,
"emitDecoratorMetadata": true,
"noEmitOnError": true
},
"files": [
"app/app.ts",
"app/benchmark.ts",
"app/global.d.ts",
"app/main-page.ts",
"app/main-view-model.ts",
"app/nativescript-angular/application.d.ts",
"app/nativescript-angular/application.ts",
"app/nativescript-angular/dom_adapter.ts",
"app/nativescript-angular/element-registry.d.ts",
"app/nativescript-angular/element-registry.ts",
"app/nativescript-angular/polyfills/array.ts",
"app/nativescript-angular/renderer.ts",
"app/nativescript-angular/view_node.ts",
"app/nativescript-angular/xhr.ts",
"app/nativescript-angular/zone.ts",
"app/nativescript-angular/zone_patch.ts",
"app/profiling.ts",
"app/renderer-test.ts",
"app/starter.ts",
"node_modules/tns-core-modules/tns-core-modules.d.ts"
],
"filesGlob": [
"node_modules/tns-core-modules/tns-core-modules.d.ts",
"app/**/*.ts"
]
"compilerOptions": {
"outDir": "app",
"rootDir": "app",
"module": "commonjs",
"target": "es5",
"inlineSourceMap": true,
"experimentalDecorators": true,
"removeComments": false,
"emitDecoratorMetadata": true,
"noEmitOnError": true
},
"files": [
"app/app.ts",
"app/benchmark.ts",
"app/global.d.ts",
"app/main-page.ts",
"app/main-view-model.ts",
"app/nativescript-angular/application.d.ts",
"app/nativescript-angular/application.ts",
"app/nativescript-angular/dom_adapter.ts",
"app/nativescript-angular/element-registry.d.ts",
"app/nativescript-angular/element-registry.ts",
"app/nativescript-angular/polyfills/array.ts",
"app/nativescript-angular/renderer.ts",
"app/nativescript-angular/view_node.ts",
"app/nativescript-angular/xhr.ts",
"app/nativescript-angular/zone.ts",
"app/nativescript-angular/zone_patch.ts",
"app/profiling.ts",
"app/renderer-test.ts",
"app/starter.ts",
"node_modules/tns-core-modules/tns-core-modules.d.ts"
],
"filesGlob": [
"node_modules/tns-core-modules/tns-core-modules.d.ts",
"app/**/*.ts"
]
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-angular",
"version": "0.0.17",
"version": "0.0.18",
"description": "",
"homepage": "http://www.telerik.com",
"bugs": "http://www.telerik.com",
Expand All @@ -14,14 +14,14 @@
},
"scripts": {},
"dependencies": {
"angular2": "2.0.0-alpha.46",
"@reactivex/rxjs": "5.0.0-alpha.7",
"angular2": "2.0.0-beta.0",
"parse5": "1.4.2",
"punycode": "1.3.2",
"querystring": "0.2.0",
"url": "0.10.3",
"reflect-metadata": "0.1.2",
"zone.js": "0.5.8"
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
"devDependencies": {
"grunt": "0.4.5",
Expand Down
2 changes: 1 addition & 1 deletion src/nativescript-angular/application.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Type, ApplicationRef, Provider } from 'angular2/angular2';
import { Type, ApplicationRef, Provider } from 'angular2/core';

export type BindingArray = Array<Type | Provider | Array<any>>;
export function nativeScriptBootstrap(appComponentType: any, componentInjectableBindings?: BindingArray): Promise<ApplicationRef>;
39 changes: 26 additions & 13 deletions src/nativescript-angular/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,49 @@ import './polyfills/array';
import './zone';
import {isPresent, Type} from 'angular2/src/facade/lang';
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {ComponentRef} from 'angular2/src/core/linker/dynamic_component_loader';
import {platform, ComponentRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/core';
import {bind, provide, Provider} from 'angular2/src/core/di';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';

import {Renderer} from 'angular2/src/core/render/api';
import {NativeScriptRenderer} from './renderer';
import {NativeScriptDomAdapter} from './dom_adapter';
import {XHR} from 'angular2/src/compiler/xhr';
import {FileSystemXHR} from './xhr';
import {Parse5DomAdapter} from 'angular2/src/core/dom/parse5_adapter';
import {Parse5DomAdapter} from 'angular2/src/platform/server/parse5_adapter';
import {ExceptionHandler} from 'angular2/src/facade/exception_handler';
import {APPLICATION_COMMON_PROVIDERS} from 'angular2/src/core/application_common_providers';
import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
import {PLATFORM_COMMON_PROVIDERS} from 'angular2/src/core/platform_common_providers';
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from "angular2/common";

import {bootstrap as angularBootstrap} from 'angular2/src/core/application';
import {commonBootstrap} from 'angular2/src/core/application_common';
import {bootstrap as angularBootstrap} from 'angular2/bootstrap';


export type BindingArray = Array<Type | Provider | any[]>;
export type ProviderArray = Array<Type | Provider | any[]>;

export function nativeScriptBootstrap(appComponentType: any,
componentInjectableBindings: BindingArray = null): Promise<ComponentRef> {
customProviders: ProviderArray = null): Promise<ComponentRef> {
NativeScriptDomAdapter.makeCurrent();

let nativeScriptBindings: BindingArray = [
let nativeScriptProviders: ProviderArray = [
NativeScriptRenderer,
provide(Renderer, {useClass: NativeScriptRenderer}),
provide(XHR, {useClass: FileSystemXHR}),
provide(ExceptionHandler, {useFactory: () => new ExceptionHandler(DOM, true), deps: []}),

provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),

APPLICATION_COMMON_PROVIDERS,
COMPILER_PROVIDERS,
PLATFORM_COMMON_PROVIDERS,
FORM_PROVIDERS,
];
var bindings = [nativeScriptBindings];
if (isPresent(componentInjectableBindings)) {
bindings.push(componentInjectableBindings);

var appProviders = [];
if (isPresent(customProviders)) {
appProviders.push(customProviders);
}

return angularBootstrap(appComponentType, bindings)
return platform(nativeScriptProviders).application(appProviders).bootstrap(appComponentType);
}
4 changes: 2 additions & 2 deletions src/nativescript-angular/dom_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Parse5DomAdapter} from 'angular2/src/core/dom/parse5_adapter';
import {setRootDomAdapter} from 'angular2/src/core/dom/dom_adapter';
import {Parse5DomAdapter} from 'angular2/src/platform/server/parse5_adapter';
import {setRootDomAdapter} from 'angular2/src/platform/dom/dom_adapter';
import {Type} from 'angular2/src/facade/lang';

export class NativeScriptDomAdapter extends Parse5DomAdapter {
Expand Down
Loading