Learning AngularJS

  • Friday, March 31, 2017 2:17 AM EST
  • Last Edited: Friday, March 31, 2017 2:20 AM EST

The following are things I learned in AngularJS that are not straightforward at beginning or are things that can be easily forgotten:

  1. Ng-if don’t use functions to evaluate true or false
    e.g. ng-if="getUser()"
  2.  Adding controller to component
    controller: ['$state', function ($state) {
    function toprogramdetails(encId) {
    $state.go('ProgramDetails', { id: encId });
    this.toprogramdetails = toprogramdetails;
  3.  Initializing values in component
    controller:function () {
    this.$onInit = function () {
    //define default values
    if ("undefined" === typeof this.clickablerow) {
    this.clickablerow = false;
    if ("undefined" === typeof this.modifyStatusAndRole) {
    this.modifyStatusAndRole = this.clickablerow;
  4. Do not use custom attributes that are already prebuilt to html e.g. onclick when defining attributes for componenets or directives. This causes a console log error, uncaught referenceerror: [referenceditem] is not defined.. 
  5. When defining components names or component attribute names with camelcase e.g. programsTable, you must refer to the capatilized letter with a dash then small letter in the html.
    Example: app.component('userTable', {…. } has to be referred to as <user-table>
comments powered by Disqus