inject angular.js app into page via javascript
علی ذوالفقار
1399/06/01 14:27:06 (868)
console.log('myJsFile.js is running');
angular.element(document).ready(function() { // if document element is ready in angular.js
console.log('angular element(document) is ready') // debug-log
var app = angular.module('app', []) // create app
.controller('myCtrl', function($scope) { // create controller
console.log('myCtrl is runnung'); // debug-log
$scope.greeting = 'Welcome!'; // set greeting in scope
});
// load html template html
$.get('/ngviews/template1.html',function(data){
console.log('inject html template') // debug-log
$('#main').html('' + data + '
'); // append template to "#main" element via jquery
console.log('bootstrap angular app'); // debug-log
angular.bootstrap(document, ['app']); // bootstrap/start angular application
});
});