Skip to content
Closed
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
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ tags
npm-debug.log
nativescript-angular*.tgz

tests/app/**/*.js
tests/test-output.txt
tests/platforms
tests/lib
tests/node_modules

tests/*/app/**/*.js
tests/*/test-output.txt
tests/*/platforms
tests/*/lib
tests/*/node_modules

ng-sample/app/**/*.js
ng-sample/app/global.d.ts
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ install:
- cd nativescript-angular
- npm install
- npm run tslint
- cd ../tests
- cd ../tests/tns
- npm install
- tns platform add android
before_script:
- echo no | android create avd --force -n test -t android-19 -b armeabi-v7a
- emulator -memory 1024 -avd test -no-audio -no-window &
script:
-
-
- cd tests/tns
- tns build android
- android-wait-for-emulator
- npm run run-appium-android
- npm run test
before_deploy:
- cd ../nativescript-angular
- npm install -g nativescript --ignore-scripts
Expand Down
69 changes: 69 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,73 @@
<a name="1.5.1"></a>
## [1.5.1](https://github.com/NativeScript/nativescript-angular/compare/v1.5.0...v1.5.1) (2017-03-30)


### Bug Fixes

* **action bar:** attach #comment nodes with _addView ([#729](https://github.com/NativeScript/nativescript-angular/issues/729)) ([be93db6](https://github.com/NativeScript/nativescript-angular/commit/be93db6)), closes [#725](https://github.com/NativeScript/nativescript-angular/issues/725)
* **ns-router-link:** navigate with urlTree ([#728](https://github.com/NativeScript/nativescript-angular/issues/728)) ([71058f8](https://github.com/NativeScript/nativescript-angular/commit/71058f8)), closes [#724](https://github.com/NativeScript/nativescript-angular/issues/724)



<a name="1.5.0"></a>
# [1.5.0](https://github.com/NativeScript/nativescript-angular/compare/v1.4.1...v1.5.0) (2017-03-22)

### Bug Fixes

* **action-bar:** Don't remove action items twice. ([677d7e0](https://github.com/NativeScript/nativescript-angular/commit/677d7e0))
* **animations:** add onDestroy method to NativeScriptAnimationPlayer ([2e24010](https://github.com/NativeScript/nativescript-angular/commit/2e24010))
* **dom_adapter:** add missing `contains` method signature ([bae45f6](https://github.com/NativeScript/nativescript-angular/commit/bae45f6))
* **dom_adapter:** update setTitle and getGlobalEventTarget to be compliant with Angular API ([25c134d](https://github.com/NativeScript/nativescript-angular/commit/25c134d))
* **gitignore:** Add editor files into gitignore ([819a960](https://github.com/NativeScript/nativescript-angular/commit/819a960))
* **init:** Bootstrap Angular on page "navigatingTo" event. ([ab04aba](https://github.com/NativeScript/nativescript-angular/commit/ab04aba))
* **list-view-comp:** IterableDiffer is now parameterized on \<KeyedTemplate\> ([780967d](https://github.com/NativeScript/nativescript-angular/commit/780967d))
* **ns-http:** make defaultOptions of type RequestOptions ([db730e2](https://github.com/NativeScript/nativescript-angular/commit/db730e2))
* **page-router-outlet:** activateWith instead of activate method ([8d832bc](https://github.com/NativeScript/nativescript-angular/commit/8d832bc))
* **page-router-outlet:** manually run detect changes when navigating to new page ([07caa74](https://github.com/NativeScript/nativescript-angular/commit/07caa74))
* **platform:** import InjectionToken and ViewEncapsulation instead of OpaqueToken ([c4dc8d4](https://github.com/NativeScript/nativescript-angular/commit/c4dc8d4))
* **platform:** import MissingTranslationStrategy ([d2328a5](https://github.com/NativeScript/nativescript-angular/commit/d2328a5))
* **renderer:** implement createComment and createText methods using Placeholders ([c0ec870](https://github.com/NativeScript/nativescript-angular/commit/c0ec870))
* **renderer:** use _eachChildView for nextSibling ([150c1ce](https://github.com/NativeScript/nativescript-angular/commit/150c1ce))
* **renderer:** use flags in `setStyle` and `removeStyle` instead of booleans ([a6d9247](https://github.com/NativeScript/nativescript-angular/commit/a6d9247))
* **ts:** ship package with reference to iterable interface ([7edfa6b](https://github.com/NativeScript/nativescript-angular/commit/7edfa6b))


### Code Refactoring

* stop exporting NativeScriptModule from platform ([#701](https://github.com/NativeScript/nativescript-angular/issues/701)) ([409e717](https://github.com/NativeScript/nativescript-angular/commit/409e717))


### Features

* **animations:** introduce NativeScriptAnimationsModule ([b5874ba](https://github.com/NativeScript/nativescript-angular/commit/b5874ba))
* **renderer:** implement simple nextSibling method using parent's _eachChildView ([98d9d20](https://github.com/NativeScript/nativescript-angular/commit/98d9d20))
* **renderer:** upgrade to be compliant with Angular 4's Renderer2 and RendererFactory2 ([a3adcca](https://github.com/NativeScript/nativescript-angular/commit/a3adcca))
* **renderer:** use EmulatedRenderer to scope component styles ([25f5111](https://github.com/NativeScript/nativescript-angular/commit/25f5111))


### BREAKING CHANGES

* **NativeScriptModule:** User applications cannot import NativeScriptModule from
"nativescript-angular/platform" anymore.
Migration:
Before:
```
import { NativeScriptModule } from "nativescript-angular/platform";
```
After
```
import { NativeScriptModule } from
"nativescript-angular/nativescript.module";
```
* **animations:** To use animations, you need to import the
NativeScriptAnimationsModule from "nativescript-angular/animations" in
your root NgModule. Also you need a dependency to "@angular/animations".

* **typescript:** The required version of TypeScript is ~2.1. Support for ~2.2 requires changes in `tns-core-modules` and will be provided with NativeScript 3.0.


# 1.1.2 (2016-10-28)

- Angular 2.1.2 compatibility release

# 1.1.1 (2016-10-21)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/NativeScript/nativescript-angular.svg?branch=master)](https://travis-ci.org/NativeScript/nativescript-angular)

Integrating NativeScript with Angular 2.
Integrating NativeScript with Angular.

# Running locally

Expand Down Expand Up @@ -68,7 +68,7 @@ npm link nativescript-angular
1. Make changes to the `test`, `ng-sample` projects or in `nativescript-angular` folder.
2. Run the `tests` or `ng-sample` using as shown above.

# Watch the video explaining Angular 2 and NativeScript
# Watch the video explaining Angular and NativeScript
[NativeScript session on AngularConnect conference](https://www.youtube.com/watch?v=4SbiiyRSIwo)

# Explore the examples
Expand Down
21 changes: 21 additions & 0 deletions build-doc-snippets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e

ENV="${ENV:-dev}"
DIST_DIR="bin/dist"
TARGET_DIR="$DIST_DIR/snippets"
PACKAGE_VERSION="${PACKAGE_VERSION:-0.0.0}"

extractSnippets() {
BIN="./node_modules/markdown-snippet-injector/extract.js"
node "$BIN" --root="." --target="$TARGET_DIR" \
--sourceext=".js|.ts|.xml|.html|.css"
}

npm install markdown-snippet-injector
rm -rf "$TARGET_DIR"
mkdir -p "$TARGET_DIR"

extractSnippets

(cd "$DIST_DIR" && tar zcvf "nativescript-angular-snippets-$ENV-$PACKAGE_VERSION.tar.gz" snippets)
2 changes: 1 addition & 1 deletion nativescript-angular/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[Get started with Angular 2 and NativeScript.](http://docs.nativescript.org/angular/start/introduction.html)
[Get started with Angular and NativeScript.](http://docs.nativescript.org/angular/start/introduction.html)
9 changes: 6 additions & 3 deletions nativescript-angular/directives/action-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Page } from "tns-core-modules/ui/page";
import { View } from "tns-core-modules/ui/core/view";
import { registerElement, ViewClassMeta, NgView } from "../element-registry";

let actionBarMeta: ViewClassMeta = {
const actionBarMeta: ViewClassMeta = {
skipAddToDom: true,
insertChild: (parent: NgView, child: NgView, _atIndex: number) => {
insertChild: (parent: NgView, child: NgView, atIndex: number) => {
const bar = <ActionBar>(<any>parent);
const childView = <any>child;

Expand All @@ -17,13 +17,16 @@ let actionBarMeta: ViewClassMeta = {
} else if (child instanceof ActionItem) {
bar.actionItems.addItem(childView);
childView.parent = bar;
} else if (child.nodeName !== "#text" && child instanceof View) {
} else if (child.nodeName === "#comment") {
bar._addView(childView, atIndex);
} else if (child instanceof View) {
bar.titleView = childView;
}
},
removeChild: (parent: NgView, child: NgView) => {
const bar = <ActionBar>(<any>parent);
const childView = <any>child;

if (child instanceof NavigationButton) {
if (bar.navigationButton === childView) {
bar.navigationButton = null;
Expand Down
44 changes: 18 additions & 26 deletions nativescript-angular/directives/list-view-comp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ import {
Host,
ChangeDetectionStrategy
} from "@angular/core";
import { isBlank } from "../lang-facade";
import { isListLikeIterable } from "../collection-facade";
import { ListView } from "tns-core-modules/ui/list-view";
import { ListView, ItemEventData } from "tns-core-modules/ui/list-view";
import { View, KeyedTemplate } from "tns-core-modules/ui/core/view";
import { ObservableArray } from "tns-core-modules/data/observable-array";
import { LayoutBase } from "tns-core-modules/ui/layouts/layout-base";
import { listViewLog } from "../trace";
import { listViewLog, listViewError } from "../trace";

const NG_VIEW = "_ngViewRef";

Expand Down Expand Up @@ -147,27 +146,31 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {
this._templateMap.set(key, keyedTemplate);
}

public onItemLoading(args) {
public onItemLoading(args: ItemEventData) {
if (!args.view && !this.itemTemplate) {
return;
}

let index = args.index;
let items = args.object.items;
let currentItem = typeof (items.getItem) === "function" ?
items.getItem(index) : items[index];
const index = args.index;
const items = (<any>args.object).items;
const currentItem = typeof items.getItem === "function" ? items.getItem(index) : items[index];
let viewRef: EmbeddedViewRef<ListItemContext>;

if (args.view && args.view[NG_VIEW]) {
if (args.view) {
listViewLog("onItemLoading: " + index + " - Reusing existing view");
viewRef = args.view[NG_VIEW];
// getting angular view from original element (in cases when ProxyViewContainer
// Getting angular view from original element (in cases when ProxyViewContainer
// is used NativeScript internally wraps it in a StackLayout)
if (!viewRef && args.view instanceof LayoutBase && args.view.getChildrenCount() > 0) {
viewRef = args.view.getChildAt(0)[NG_VIEW];
}

if (!viewRef) {
viewRef = (args.view._subViews && args.view._subViews.length > 0) ?
args.view._subViews[0][NG_VIEW] : undefined;
listViewError("ViewReference not found for item " + index + ". View recycling is not working");
}
} else {
};

if (!viewRef) {
listViewLog("onItemLoading: " + index + " - Creating view from template");
viewRef = this.loader.createEmbeddedView(this.itemTemplate, new ListItemContext(), 0);
args.view = getItemViewRoot(viewRef);
Expand All @@ -180,9 +183,6 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {
}

public setupViewRef(viewRef: EmbeddedViewRef<ListItemContext>, data: any, index: number): void {
if (isBlank(viewRef)) {
return;
}
const context = viewRef.context;
context.$implicit = data;
context.item = data;
Expand All @@ -194,13 +194,9 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {
}

private detectChangesOnChild(viewRef: EmbeddedViewRef<ListItemContext>, index: number) {
// Manually detect changes in child view ref
// TODO: Is there a better way of getting viewRef"s change detector
const childChangeDetector = <ChangeDetectorRef>(<any>viewRef);

listViewLog("Manually detect changes in child: " + index);
childChangeDetector.markForCheck();
childChangeDetector.detectChanges();
viewRef.markForCheck();
viewRef.detectChanges();
}

ngDoCheck() {
Expand Down Expand Up @@ -243,10 +239,6 @@ export type RootLocator = (nodes: Array<any>, nestLevel: number) => View;

export function getItemViewRoot(viewRef: ComponentView, rootLocator: RootLocator = getSingleViewRecursive): View {
const rootView = rootLocator(viewRef.rootNodes, 0);
rootView.on("unloaded", () => {
viewRef.destroy();
delete rootView[NG_VIEW];
});
return rootView;
}

Expand Down
57 changes: 40 additions & 17 deletions nativescript-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
{
"private": true,
"name": "nativescript-angular",
"version": "2.0.0",
"description": "An Angular 2 renderer that lets you build mobile apps with NativeScript.",
"homepage": "http://www.telerik.com",
"bugs": "http://www.telerik.com",
"version": "3.0.0",
"description": "An Angular renderer that lets you build mobile apps with NativeScript.",
"homepage": "https://www.nativescript.org/",
"bugs": "https://github.com/NativeScript/nativescript-angular/issues",
"author": {
"name": "NativeScript Team"
},
"contributors": [
"Hristo Deshev <hristo.deshev@telerik.com>"
"Hristo Deshev <hristo.deshev@telerik.com>",
"Alexander Vakrilov <alexander.vakrilov@progress.com>",
"Stanimira Vlaeva <Stanimira.Vlaeva@progress.com>"
],
"nativescript": {
"platforms": {
"android": "3.0.0",
"ios": "3.0.0"
}
},
"keywords": [
"NativeScript",
"Angular"
],
"license": "Apache-2.0",
"repository": {
Expand All @@ -24,29 +39,37 @@
"update-app-ng-deps": "./bin/update-app-ng-deps"
},
"dependencies": {
"nativescript-intl": "~0.0.8",
"nativescript-intl": "^0.0.8",
"reflect-metadata": "^0.1.8"
},
"peerDependencies": {
"@angular/core": "~4.0.0",
"@angular/common": "~4.0.0",
"@angular/compiler": "~4.0.0",
"@angular/http": "~4.0.0",
"@angular/platform-browser": "~4.0.0",
"@angular/platform-browser-dynamic": "~4.0.0",
"@angular/forms": "~4.0.0",
"@angular/animations": "~4.0.0",
"@angular/router": "~4.0.0",
"@angular/forms": "~4.0.0",
"@angular/http": "~4.0.0",
"tns-core-modules": "^3.0.0 || ^3.0.0-rc.1",
"rxjs": "^5.0.1",
"reflect-metadata": "~0.1.8",
"punycode": "1.3.2",
"querystring": "0.2.0",
"url": "0.10.3"
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/animations": "~4.0.0",
"@angular/core": "~4.0.0",
"@angular/common": "~4.0.0",
"@angular/compiler": "~4.0.0",
"@angular/compiler-cli": "~4.0.0",
"@angular/platform-browser": "~4.0.0",
"@angular/animations": "~4.0.0",
"@angular/router": "~4.0.0",
"@angular/forms": "~4.0.0",
"@angular/http": "~4.0.0",
"codelyzer": "~3.0.0-beta.4",
"tns-core-modules": "internal-preview",
"tslint": "~4.5.0",
"typescript": "~2.2.1",
"zone.js": "^0.8.2"
},
"nativescript": {}
"rxjs": "^5.0.1",
"zone.js": "^0.8.4"
}
}
10 changes: 4 additions & 6 deletions nativescript-angular/router/ns-router-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,19 @@ export class NSRouterLink implements OnChanges { // tslint:disable-line:directiv
JSON.stringify(this.pageTransition));

const extras = this.getExtras();
this.navigator.navigate(this.commands, extras);
this.navigator.navigateByUrl(this.urlTree, extras);
}

private getExtras() {
private getExtras(): NavigationExtras & NavigationOptions {
const transition = this.getTransition();
const extras: NavigationExtras & NavigationOptions = {
return {
queryParams: this.queryParams,
fragment: this.fragment,
clearHistory: this.clearHistory,
animated: transition.animated,
transition: transition.transition,
relativeTo: this.currentRoute,
};

return (<any>Object).assign(extras,
this.currentRoute.toString() !== "Route(url:'', path:'')" && this.currentRoute);
}

private getTransition(): { animated: boolean, transition?: NavigationTransition } {
Expand Down
Loading