/**
 * myApp Module
 *
 * Description
 */
angular.module('myApp', []).directive('contenteditable', function(){
	// Runs during compile
	return {
		require: 'ngModel',
		link: function($scope, iElm, iAttrs, controller) {
			// view -> model
			iElm.bind('keyup', function() {
				$scope.$apply(function() {
					controller.$setViewValue(iElm.text());
				});
			});
			// model -> view
			controller.$render = function() {
				iElm.html(controller.$viewValue);
			};
			// load init value from DOM
			controller.$setViewValue(iElm.html());
		}
	};
});