Skip to content

Instantly share code, notes, and snippets.

@geddski
Created May 13, 2013 22:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save geddski/5571990 to your computer and use it in GitHub Desktop.
Save geddski/5571990 to your computer and use it in GitHub Desktop.
/*
How to use Angular inside a Backbone view.
*/
var ViewWithAngular = Backbone.View.extend({
render: function(container){
var $injector = angular.injector(['ng', 'mason']);
$injector.invoke(function($rootScope, $compile){
var elem = $compile('<h1 ng-controller="NestedCtrl">Backbone View with nested Angular. Message: {{message}}</h1>')($rootScope);
container.html(elem);
$rootScope.$apply();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment