I'm just learning angularjs and have something working mixing jQuery with the angularjs. I know this isn't the correct way, but I don't know what is the Angularjs correct way to do this.
In the HTML I have this tag which is just a button to add the div tag dynamically onto the page.
<div ng-controller="pgCtrl">
<button id="new-btn" ng-click="newDiv()">Gimme a div!</button>
</div>
In the javascript I have this:
app.controller('pgCtrl', function($scope){
$scope.newDiv = function(){
// Load an element that uses controller anotherCtrl
$('<div class="blah" ng-controller="anotherCtrl">' +
'<button id="another-btn" ng-click="stuff()">-</button>{{stuff}}' +
'</div>').appendTo('body');
angular.bootstrap($('.blah'), ['app']);
};
});
I know this isn't the "proper" way to do this with Angularjs. I'm mixing in vary basic jQuery and it works, but I'm not learning anything doing this.