18.05.2016 Views

Mittwoch, 18. Mai, 2016

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Finishing Angular TODO application and deploying to production 129<br />

36 <br />

37 <br />

38 Hello , Logout?<br />

40 <br />

41 <br />

42 <br />

43 <br />

44 <br />

45 <br />

46 <br />

47<br />

48 <br />

49 <br />

50 <br />

51 edit<br />

52 delete<br />

53 <br />

54 <br />

55 <br />

56 <br />

57 <br />

58 <br />

59 <br />

Again, the important part here is the one in the tag where you show the todo title, creation<br />

date and comment. Additionally, if the logged in user is the creator of the particular todo then two<br />

additional links will be shown (edit and delete) using the ng-show directive. The data-ng-bind is<br />

actually the same as if you would write ng-bind, but some validators tend to complain for the latter<br />

(you can learn more about it here²⁰⁶). Also, if you ever wondered what’s the deal with ng-bind vs<br />

ng-model, you can learn more here²⁰⁷, but a very nice summary is this:<br />

• ng-bind has one-way data binding ($scope -> view). It has a shortcut {{val}} which<br />

displays the scope value $scope.val inserted into HTML where val is a variable<br />

name.<br />

• ng-model is intended to be put inside of form elements and has two-way data<br />

binding ($scope -> view and view -> $scope) e.g. input ng-model=”val”.<br />

There’s one more novelty in this file - the data-ng-init directive. Yes, you’ve guessed it right from<br />

the name - it actually triggers the function findOneupon initialization, defined before on the scope<br />

object of TodosController controller.<br />

²⁰⁶http://stackoverflow.com/questions/16589853/ng-app-vs-data-ng-app-what-is-the-difference<br />

²⁰⁷http://stackoverflow.com/questions/12419619/whats-the-difference-between-ng-model-and-ng-bind

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!