i like to make a custom component using directive. i checked lot of tutorials and its get confusing me can anyone explain how a directive works. the component i am planing to make is
<shout-list></shout-list>
the template for shout list will be like this
<div class="shout" ng-repeat="shout in shouts">
<p>{{shout.message}}</p>
<img src="media/images/delete.png" width="32" height="32" ng-click="deleteShout({{$index}},'{{shout._id}}')"/>
</div>
Here’s your directive, with some inline comments:
And the template file:
And now you can use it in your code, like so:
Controller:
View:
Hope this helps!