The backend provides a fully rendering site, and in the frontend I want angularjs to handle dynamic content using the ajax-call / data binding, but if you deliver the ng-bind directive, then angularjs binds them directly to their initial value, which is NULL before any user action.
I found a hacker solution, but I wanted to know if there is a better 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 ... as soon as js loads, the actual value "server side hola" (server side delivered) is gone. I want the innerhtml / value to remain the same and keep the binding active, but lazy, so that it would only change it after the action, it is important that angularjs does not overwrite which server side has already been written (fixed)
<html ng-app="myApp"> <head> <meta charset="UTF-8"> <title>Title of the document</title> </head> <body > <div ng-controller="GreetingController"> <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 (){ </script> </html>
source share