AngularJS and Javascript Tips

posted in: Uncategorized | 0

This is part five of my look into AngularJS.

  1. AngularJS Intro and Setup
  2. AngularJS and Modernizr
  3. AngularJS and jQueryUI DatePicker
  4. AngularJS with TextArea and Scroll To
  5. AngularJS and Javascript Tips
  6. Coming soon…

 

AngularJS

AngularJS functions that can be used instead of using typeof(). For instance angular.isUndefined() can be used instead of doing typeof(a) === 'undefined'. Below is a list of some these functions which can be found in the AngularJS documentation.

 

Strict Contextual Escaping (sce)

In AngularJS, to send unicode characters from Javascript to HTML you need to use angular-sanitize.

Include the AngularJS service $sce in the controllers.js.

Then in HTML:

For more information on $sce head over and read the AngularJS documentation on $sce.

For more on ngSanitize read: Using ngSanitize to render HTML strings in Angular
 

Javascript

The equal:
A single = is an assignment
e.g. var a = b;

A double == is an equal
e.g. if( 1 == 2 ) // this will be false

A triple === is a strict equal to
e.g.

Two references that might be helpful:

  1. JavaScript Triple Equals Operator vs Double Equals Operator ( === vs == )
  2. Triple (3) Equal Signs [duplicate]

More examples can be found on GitHub: True, False and Equal in JS.