Phil 11.28.14

7:30 – 4:30 SR

  • Angular
  • Let’s try building a directive that we use ng-repeat on. Not too bad! Here’s how I did it:

Directive javascript:

pa.directive('oldPost', ['$window', function($window) {
 return {
 templateUrl: 'directives/oldPost.html',
 restrict: 'AE',
 scope: {pobj: '='}
 }
}]);

Directive HTML (directives.oldPost.html):

<div class="inputWrapper">
 <div class="textLabel">Posted: {{pobj.postDate}}</div>
 <textArea class="textAreaOutput" ng-model="pobj.postText" ng-disabled="true"></textArea>
</div>

Master HTML:

<div ng-repeat="pobj in mainCtrl.postItems">
 <old-post pobj = "pobj"></old-post>
</div>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: