Created
January 9, 2014 13:16
-
-
Save danielpsf/8333968 to your computer and use it in GitHub Desktop.
This is a really simple way to get a formatted string from the database and put it into front end with AngularJS. You can see it working here: https://gist.github.com/danielpsf/8333968
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body ng-app="myApp" ng-controller="myController"> | |
<div my-directive> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myApp = angular.module('myApp', []); | |
myApp.controller('myController', ['$scope', function($scope) { | |
$scope.myTemplateStr = '<p>My name is <strong>Daniel</strong></p>'; | |
}]); | |
myApp.directive('myDirective', [function() { | |
return function(scope, element, attrs) { | |
element.html(scope.myTemplateStr); | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment