Skip to content

Instantly share code, notes, and snippets.

@randombrad
Forked from anonymous/controller.js
Last active August 29, 2015 14:06
Show Gist options
  • Save randombrad/a862996379261605ba49 to your computer and use it in GitHub Desktop.
Save randombrad/a862996379261605ba49 to your computer and use it in GitHub Desktop.

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

Also need to add to portal-ext.properties "velocity.engine.restricted.variables="

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