This blog is running on jekyll; and since I’m learning AngularJS, I want to try AngularJS on my blog as well. The problem is both are using double curly braces syntax, jekyll will consume it first when generating and AngularJS will be left with nothing.
In order to use AngularJS with jekyll, we have to instruct AngularJS to use different start and end symbol by using $interpolateProvider.
var myApp = angular.
##Update ng-model of one controller from another
Using $broadcast to broadcast a message (or $emit) and put listener on that message on receiver.
// unrelated controllers -> $rootScope broadcasts App.controller('Ctrl1', function($rootScope, $scope) { $rootScope.$broadcast('msgid', msg); }); App.controller('Ctrl2', function($scope) { $scope.$on('msgid', function(event, msg) { console.log(msg); }); }); When to use $broadcast and when to use $emit?
$broadcast — dispatches the event downwards to all child scopes,
$emit — dispatches the event upwards through the scope hierarchy.
I started a HTML5 hybrid mobile app project recently. Before I start coding the frontend, I had to decide which client side JavaScript framework I will be using. The choice narrows down between AngularJS (Ionic framework) and Ember.
Of those two, AngularJS is obviously the more popular choice. There’re many frameworks built on AngularJS; thousands of questions on StackOverflow; lots of open-source projects base on AngularJS on GitHub. There are many great frameworks out there but few has gained so much developer mindshare like AngularJS.