Skip to content

Commit b6b738b

Browse files
f4e6994 feat(NgTemplateOutlet): add NgTemplateOutlet directive
1 parent c921a96 commit b6b738b

45 files changed

Lines changed: 841 additions & 658 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BUILD_INFO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Wed Apr 20 04:43:19 UTC 2016
2-
45f5df371db71ed20870beef0c1d5afc2517b256
1+
Wed Apr 20 04:45:19 UTC 2016
2+
f4e6994634a9cf6c2c20aa8c2268233e2667edf8

_analyzer.dart

Lines changed: 525 additions & 521 deletions
Large diffs are not rendered by default.

lib/platform/common.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Platform agnostic services.
3+
* Can be used both in the browser and on the server.
4+
*/
5+
library angular2.platform.common;
6+
7+
export "package:angular2/src/platform/location.dart";

lib/platform/common_dom.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
2-
* This is a set of classes and objects that can be used both in the browser and on the server.
2+
* This is a set of DOM related classes and objects that can be used both in the browser and on the
3+
* server.
34
*/
45
library angular2.platform.common_dom;
56

lib/platform/testing/browser_static.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import "package:angular2/src/mock/view_resolver_mock.dart"
2222
show MockViewResolver;
2323
import "package:angular2/src/mock/mock_location_strategy.dart"
2424
show MockLocationStrategy;
25-
import "package:angular2/src/router/location/location_strategy.dart"
26-
show LocationStrategy;
25+
import "package:angular2/platform/common.dart" show LocationStrategy;
2726
import "package:angular2/src/mock/ng_zone_mock.dart" show MockNgZone;
2827
import "package:angular2/src/platform/browser/xhr_impl.dart" show XHRImpl;
2928
import "package:angular2/compiler.dart" show XHR;

lib/router.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,8 @@ export "src/router/router.dart" show Router;
99
export "src/router/directives/router_outlet.dart" show RouterOutlet;
1010
export "src/router/directives/router_link.dart" show RouterLink;
1111
export "src/router/instruction.dart" show RouteParams, RouteData;
12-
export "src/router/location/platform_location.dart" show PlatformLocation;
1312
export "src/router/route_registry.dart"
1413
show RouteRegistry, ROUTER_PRIMARY_COMPONENT;
15-
export "src/router/location/location_strategy.dart"
16-
show LocationStrategy, APP_BASE_HREF;
17-
export "src/router/location/hash_location_strategy.dart"
18-
show HashLocationStrategy;
19-
export "src/router/location/path_location_strategy.dart"
20-
show PathLocationStrategy;
21-
export "src/router/location/location.dart" show Location;
2214
export "src/router/route_config/route_config_decorator.dart";
2315
export "src/router/route_definition.dart";
2416
export "src/router/interfaces.dart"

lib/src/common/directives.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ library angular2.src.common.directives;
88
export "directives/ng_class.dart" show NgClass;
99
export "directives/ng_for.dart" show NgFor;
1010
export "directives/ng_if.dart" show NgIf;
11+
export "directives/ng_template_outlet.dart" show NgTemplateOutlet;
1112
export "directives/ng_style.dart" show NgStyle;
1213
export "directives/ng_switch.dart" show NgSwitch, NgSwitchWhen, NgSwitchDefault;
1314
export "directives/ng_plural.dart" show NgPlural, NgPluralCase, NgLocalization;

lib/src/common/directives/core_directives.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "package:angular2/src/facade/lang.dart" show Type;
44
import "ng_class.dart" show NgClass;
55
import "ng_for.dart" show NgFor;
66
import "ng_if.dart" show NgIf;
7+
import "ng_template_outlet.dart" show NgTemplateOutlet;
78
import "ng_style.dart" show NgStyle;
89
import "ng_switch.dart" show NgSwitch, NgSwitchWhen, NgSwitchDefault;
910
import "ng_plural.dart" show NgPlural, NgPluralCase;
@@ -52,6 +53,7 @@ const List<Type> CORE_DIRECTIVES = const [
5253
NgClass,
5354
NgFor,
5455
NgIf,
56+
NgTemplateOutlet,
5557
NgStyle,
5658
NgSwitch,
5759
NgSwitchWhen,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
library angular2.src.common.directives.ng_template_outlet;
2+
3+
import "package:angular2/core.dart"
4+
show Directive, Input, ViewContainerRef, ViewRef, TemplateRef;
5+
import "package:angular2/src/facade/lang.dart" show isPresent;
6+
7+
/**
8+
* Creates and inserts an embedded view based on a prepared `TemplateRef`.
9+
*
10+
* ### Syntax
11+
* - `<template [ngTemplateOutlet]="templateRefExpression"></template>`
12+
*/
13+
@Directive(selector: "[ngTemplateOutlet]")
14+
class NgTemplateOutlet {
15+
ViewContainerRef _viewContainerRef;
16+
ViewRef _insertedViewRef;
17+
NgTemplateOutlet(this._viewContainerRef) {}
18+
@Input()
19+
set ngTemplateOutlet(TemplateRef templateRef) {
20+
if (isPresent(this._insertedViewRef)) {
21+
this
22+
._viewContainerRef
23+
.remove(this._viewContainerRef.indexOf(this._insertedViewRef));
24+
}
25+
if (isPresent(templateRef)) {
26+
this._insertedViewRef =
27+
this._viewContainerRef.createEmbeddedView(templateRef);
28+
}
29+
}
30+
}

lib/src/mock/location_mock.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "package:angular2/src/core/di.dart" show Injectable;
44
import "package:angular2/src/facade/async.dart"
55
show EventEmitter, ObservableWrapper;
66
import "package:angular2/src/facade/collection.dart" show ListWrapper;
7-
import "package:angular2/src/router/location/location.dart" show Location;
7+
import "package:angular2/platform/common.dart" show Location;
88

99
/**
1010
* A spy for [Location] that allows tests to fire simulated location events.

0 commit comments

Comments
 (0)