The backend delivers a fully rendered site and on the frontend I want for angularjs to handle the dynamic content through ajax-call /data binding but if you deliver the directive ng-bind then angularjs binds them directly to their initial value which is NULL before any user action.
I found a hacky solution but I wanted to know if there is a better one or maybe another js framework that does exactly what I'm trying to do :
https://github.com/herschel666/angular-lazy-bind
the following example should help to understand my problem... once js is loaded the inital value "hola server side"(server side delivered) is gone. I want for the innerhtml/value to stay like that and keep the binding active but lazy so that it would only change it after an action the important thing is for angularjs to not rewrite what server side has already been writen(redered)
<html ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>
<body >
<div ng-controller="GreetingController">
<!-- this value has to stay ... but keep its binding property in order to change it afer an user action -->
<span ng-bind="greeting"> hola server side</span>
<button ng-click="update()">update</button>
</div>
</body>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>
<script type="text/javascript">
var myApp = angular.module('myApp',[]);
myApp.controller('GreetingController', ['$scope', function($scope) {
$scope.update = function (){
//do ajax calls and set greeting and other data to bind
$scope.greeting = 'Hola!';
}
}]);
</script>
</html>
ngBind
attribute tells Angular to replace the text content of the specified HTML element with the value of a given expression, and to update the text content when the value of that expression changes. – Monitor