Skip to content

Instantly share code, notes, and snippets.

@planetsizebrain
Created March 3, 2016 20:08
Show Gist options
  • Save planetsizebrain/eb222c689d2dd188a34d to your computer and use it in GitHub Desktop.
Save planetsizebrain/eb222c689d2dd188a34d to your computer and use it in GitHub Desktop.
Angular Hello World test with code from Gyle Fernandez
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="theme" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<portlet:defineObjects />
<theme:defineObjects />
<div id="<portlet:namespace />app" class="co-app">
<table ng-controller="listCtrl" id="listCtrl">
<thead>
<tr>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="data in alldata">
<td>{{data.effectiveDateTime}}</td>
</tr>
</tbody>
</table>
</div>
<aui:script use="aui-base" position="inline">
var app = angular.module('<portlet:namespace />', []);
app.factory("services", ['$http', function($http) {
var serviceBase = '/angular-hello-world-portlet/data/local.json';
var obj = {};
obj.getData = function() {
return $http.get(serviceBase)
}
return {
getData: obj.getData
}
}]);
app.controller('listCtrl', function($scope, services) {
services.getData().then(function(data) {
$scope.alldata = data.data;
});
});
angular.bootstrap(document.getElementById('<portlet:namespace />app'), ['<portlet:namespace />']);
</aui:script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment