Skip to content

Instantly share code, notes, and snippets.

Created September 11, 2014 16:21
Show Gist options
  • Save anonymous/ca4510837321c97ed793 to your computer and use it in GitHub Desktop.
Save anonymous/ca4510837321c97ed793 to your computer and use it in GitHub Desktop.
Use Web Content to create angular content

Add Custom Field of "controller" to the Web Content Scope. Then when editing web content under custom fields add the controller.js content

function FirstCtrl($scope){
$scope.data = {message: "Hello"};
}
<div ng-app="">
<h1>App 2</h1>
<div ng-controller="FirstCtrl">
<h1>{{data.message + " world"}}</h1>
<div class="{{data.message}}">Wrap me in a foundation component</div>
</div>
</div>
#set ($JournalArticleService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleService"))
#set ($JournalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#set ($JournalArticle = $JournalArticleLocalService.getArticle($getterUtil.getLong($groupId),"$reserved-article-id.data"))
#set ($controllerJS = $JournalArticle.getExpandoBridge().getAttribute("controller"))
${content.getData()}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
#if ($controllerJS)
<script type="text/javascript">
$controllerJS
</script>
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment