Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 7905623

Browse files
author
SamGraber
committed
Documented genericContainer. Linked to the docs from the examples in the bootstrapper.
1 parent 5ab56eb commit 7905623

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Angular components that can be added to an application.
4242
* [commaList](/source/components/commaList/commaList.md)
4343
* [dateTimeStatic](/source/components/dateTimeStatic/dateTimeStatic.md)
4444
* [dialog](/source/components/dialog/dialog.md)
45-
* [genericContainer]()
45+
* [genericContainer](/source/components/genericContainer/genericContainer.md)
4646
* [form](/source/components/form/form.md)
4747
* [lazyLoad](/source/components/lazyLoad/lazyLoad.md)
4848
* [messageLog]()

bootstrapper/bootstrapper.js

+3
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@
223223
function MiscTestController($scope, $q, $timeout, dialog, cardContainerBuilderFactory) {
224224
var self = this;
225225
// Misc
226+
self.myNum = 2;
227+
self.myValue = 1;
228+
226229
self.validator = {
227230
validate: function () {
228231
return self.text === 'valid';

bootstrapper/misc.html

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
<h3>Misc</h3>
22
<div>
3-
<label>Generic container:</label>
3+
<label><a href="https://github.com/SamGraber/TypeScript-Angular-Components/blob/master/source/components/genericContainer/genericContainer.md">Generic container:</a></label>
4+
<rl-radio-group ng-model="misc.myValue">
5+
<rl-radio value="1">1</rl-radio>
6+
<rl-radio value="2">2</rl-radio>
7+
<rl-radio value="3">3</rl-radio>
8+
</rl-radio-group>
9+
<rl-generic-container selector="misc.myValue">
10+
<template when-selector="1"><span>Template 1</span></template>
11+
<template when-selector="{{misc.myNum}}"><span>Template 2</span></template>
12+
<template default><span>Default</span></template>
13+
</rl-generic-container>
414
<rl-checkbox ng-model="misc.toggle">Toggle</rl-checkbox>
515
<rl-generic-container selector="misc.toggle">
616
<template default>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generic container
2+
A component that uses an expression to conditionally display a template. Functions similar to [`ng-switch`](https://docs.angularjs.org/api/ng/directive/ngSwitch) with the significant difference that expressions are supported in the `when` operators, where `ng-switch` only allows for primitive values.
3+
4+
### Usage
5+
```
6+
<rl-generic-container selector="">
7+
<template when-selector=""> ... </template>
8+
<template default> ... </template>
9+
</rl-generic-container>
10+
```
11+
### Options
12+
13+
#### `selector`
14+
An expression that evaluates to a string value representing the template that should be shown. If no match is found, the default is used.
15+
16+
#### `when-selector`
17+
Specifies the value that the container should match against to determine if this template should be shown. Unlike `ng-switch`, interpolation is permitted.
18+
19+
#### `default (default: false)`
20+
If specified, the specified template is used if no match is found. In this case, no `when-selector` need be specified.
21+
22+
Template contents must be surrounded with an html tag to function correctly.
23+
24+
### Full example
25+
```
26+
// myNum = 2
27+
<rl-generic-container selector="myValue">
28+
<template when-selector="1">Template 1</template>
29+
<template when-selector="{{myNum}}">Template 2</template>
30+
<template default>Default</template>
31+
</rl-generic-container>
32+
```
33+
Output (myValue = 1):
34+
```
35+
<div id="container"><span>Template 1</span></div>
36+
```
37+
Output (myValue = 2):
38+
```
39+
<div id="container"><span>Template 2</span></div>
40+
```
41+
Output (myValue = 3):
42+
```
43+
<div id="container"><span>Default</span></div>
44+
```

0 commit comments

Comments
 (0)