Skip to content

Commit

Permalink
added a remark related to #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Youcef Mammar committed May 21, 2014
1 parent 9dbf249 commit eb4a02c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ define([
<ng-progress-bar value="30"></ng-progress-bar>
```

<a id="init"></a>
### Initialize the widget
While attributes can perfectly initialize your widget, you may want do this when your widget instance is created,
for some specific widgets that require it.
Expand Down Expand Up @@ -110,22 +111,28 @@ This will produce the following scope

#### Accessing the entire widget instance from parent scope
The deliteful widget can be accessed in the parent scope when an `id` attribute is added in the directive.

```html
<div ng-controller="ParentCtrl">
<ng-my-widget name="Bob" id="myWidget"></ng-my-widget>
This guys name is {{myWidget.name}}
</div>
```

```js
function ParentCtrl($scope){
$scope.rename = function(){
$scope.myWidget.name = "Paul";
}
}
```

You can also use `data-id` or `x-id` instead, as `id` must be unique to an entire page,
wherease our variable is unique to the parent scope only.

NB: you can't use this to initialize you widget from the controller, cf. https://github.com/tkrugg/angular-delite/issues/1
Instead use [this](#init).

### Store

Any store instance can be wrapped a regular angular module with `ngStore`
Expand Down

0 comments on commit eb4a02c

Please sign in to comment.