-- angularjs tree grid
http://khan4019.github.io/tree-grid-directive/test/treeGrid.html
-- Angular UI Grid
-- angularjs tree grid
http://khan4019.github.io/tree-grid-directive/test/treeGrid.html
-- Angular UI Grid
<!doctype html>
<html>
<head>
<title>Hello AngularJS</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href="../css/ng-grid.min.css" rel="stylesheet">
<style type="text/css">
.gridStyle {
border: 1px solid rgb(212, 212, 212);
width: 100%;
height: 700px;
font: 12px Tahoma;
color: #777;
}
</style>
</head>
<body>
<div ng-app="app01">
<div ng-controller='appctrl01'>
<div class="gridStyle" ng-grid="gridOptions"></div>
</div>
</div>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script> -->
<script src="../js/jquery.min.js"></script>
<script src="../js/angular.min.js"></script>
<script src="../js/ng-grid.min.js"></script>
<script src="../js/ui-grid.js"></script>
<script type="text/javascript">
var newsModule = angular.module('app01', [ 'ngGrid' ]);
newsModule.controller('appctrl01', fnNewsCtrl);
function fnNewsCtrl($scope, $http) {
$http.get('https://api.getevents.co/event?&lat=41.904196&lng=12.465974').success(
function(data)
{
$scope.successData = data.events;
});
$scope.gridOptions = {
data : 'successData',
enableCellSelection : false,
enableRowSelection : false,
enableCellEdit : false,
columnDefs : [
{field : 'id',displayName : 'id',enableCellEdit : true},
{field : 'name',displayName : 'name',enableCellEdit : true},
{field : 'city_meta.area',displayName : 'city_meta.area',enableCellEdit : true},
{field : 'city_meta.area_code',displayName : 'city_meta.area_code',enableCellEdit : true},
{field : 'source_name',displayName : 'source_name',enableCellEdit : true},
{field : 'image_large_url',displayName : 'image_large_url',enableCellEdit : true},
{field :'image_large_url', displayName:'image_large_url', cellTemplate: '<img ng-src="{{row.getProperty(\'image_large_url\')}}"></img>'}
]
};
}
</script>
</body>
</html>
<div ng-app="firstApp"> <div ng-controller="FirstController"> <p>1: {{ desc }}</p> </div> </div> <div ng-app="secondApp"> <div ng-controller="SecondController"> <p>2: {{ desc }}</p> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.7/angular.js"></script> <script type="text/javascript"> var firstApp = angular.module('firstApp', []); firstApp.controller('FirstController', function($scope) { $scope.desc = "First app."; }); var secondApp = angular.module('secondApp', []); secondApp.controller('SecondController', function($scope) { $scope.desc = "Second app."; }); </script>And below is the output. Out of 2 ng-app present on the page, the first one gets initialized and works as expected. Output also shows the same.
1: First app. 2: {{ desc }}
var firstApp = angular.module('firstApp', []); firstApp.controller('FirstController', function($scope) { $scope.desc = "First app. "; }); var secondApp = angular.module('secondApp', []); secondApp.controller('SecondController', function($scope) { $scope.desc = "Second app. "; }); var dvFirst = document.getElementById('dvFirst'); var dvSecond = document.getElementById('dvSecond'); angular.element(document).ready(function() { angular.bootstrap(dvFirst, ['firstApp']); angular.bootstrap(dvSecond, ['secondApp']); });Since we are bootstrapping them manually, make sure to remove ng-app attribute from the HTML page.
var firstApp = angular.module('firstApp', []); firstApp.controller('FirstController', function($scope) { $scope.desc = "First app. "; }); var secondApp = angular.module('secondApp', []); secondApp.controller('SecondController', function($scope) { $scope.desc = "Second app. "; }); var dvSecond = document.getElementById('dvSecond'); angular.element(document).ready(function() { angular.bootstrap(dvSecond, ['secondApp']); });So make sure that there is
var rootApp = angular.module('rootApp', ['firstApp','secondApp']); var firstApp = angular.module('firstApp', []); firstApp.controller('FirstController', function($scope) { $scope.desc = "First app. "; }); var secondApp = angular.module('secondApp', []); secondApp.controller('SecondController', function($scope) { $scope.desc = "Second app. "; });And make sure any parent node (body/Parent div) is assigned with ng-app=rootApp".
Only one AngularJS application can be auto-bootstrapped per HTML document. The first ngApp found in the document will be used to define the root element to auto-bootstrap as an application. To run multiple applications in an HTML document you must manually bootstrap them using angular.bootstrap instead. AngularJS applications cannot be nested within each other. |
<!DOCTYPE html> <html> <head> <title>Multiple ngApp does not work</title> </head> <body> <div ng-app="firstApp"> <div ng-controller="FirstController"> <p> 1# {{ name }} </p> </div> </div> <div ng-app="secondApp"> <div ng-controller="SecondController"> <p> 2# {{ name }} </p> </div> </div> <script src="angular.js"></script> <script type="text/javascript"> var firstApp = angular.module('firstApp', []); firstApp.controller('FirstController', function($scope) { $scope.name = "I'm the first app."; }); var secondApp = angular.module('secondApp', []); secondApp.controller('SecondController', function($scope) { $scope.name = "I'm the second app."; }); </script> </body> </html> |
1# I'm the first app. 2# {{ name }} |
<!DOCTYPE html> <html> <head> <title>Injecting modules as dependencies of the root app </title> </head> <body ng-app="rootApp"> <div id="firstApp"> <div ng-controller="FirstController"> <p>1# {{ name }}</p> </div> </div> <div id="secondApp"> <div ng-controller="SecondController"> <p>2# {{ name }}</p> </div> </div> <script src="angular.js"></script> <script type="text/javascript"> // passing the two modules as dependencies of the root module var rootApp = angular.module('rootApp', ['firstApp','secondApp']); var firstApp = angular.module('firstApp', []); firstApp.controller('FirstController', function ($scope) { $scope.name = "I'm the first app."; }); var secondApp = angular.module('secondApp', []); secondApp.controller('SecondController', function ($scope) { $scope.name = "I'm the second app."; }); </script> </body> </html> |
1# I'm the first app. 2# I'm the second app. |
<!DOCTYPE html> <html> <head> <title>Manual bootstrapping the second module</title> </head> <body> <div ng-app="firstApp"> <div ng-controller="FirstController"> <p>1# {{ name }}</p> </div> </div> <!-- using id attribute instead of ng-app --> <div id="secondApp"> <div ng-controller="SecondController"> <p>2# {{ name }}</p> </div> </div> <script src="angular.js"></script> <script type="text/javascript"> var firstApp = angular.module('firstApp', []); firstApp.controller('FirstController', function($scope) { $scope.name = "I'm the first app."; }); var secondApp = angular.module('secondApp', []); secondApp.controller('SecondController', function($scope) { $scope.name = "I'm the second app."; }); // manually boostrapping the second app var secondDiv = document.getElementById('secondApp'); angular.element(document).ready(function() { angular.bootstrap(secondDiv, [ 'secondApp' ]); }); </script> </body> </html> |
<!DOCTYPE html> <html> <head> <title>Manual boostrapping both modules</title> </head> <body> <!-- using id attribute instead of ng-app --> <div id="firstApp"> <div ng-controller="FirstController"> <p>1# {{ name }}</p> </div> </div> <!-- using id attribute instead of ng-app --> <div id="secondApp"> <div ng-controller="SecondController"> <p>2# {{ name }}</p> </div> </div> <script src="angular.js"></script> <script type="text/javascript"> var firstApp = angular.module('firstApp', []); firstApp.controller('FirstController', function($scope) { $scope.name = "I'm the first app."; }); var secondApp = angular.module('secondApp', []); secondApp.controller('SecondController', function($scope) { $scope.name = "I'm the second app."; }); var firstDiv = document.getElementById('firstApp'); var secondDiv = document.getElementById('secondApp'); // manually boostrapping the second app angular.element(document).ready(function() { angular.bootstrap(firstDiv, [ 'firstApp' ]); angular.bootstrap(secondDiv, [ 'secondApp' ]); }); </script> </body> </html> |