Is there a way to have an HTML view with pre-populated values ββfrom the server and then get AngularJS to read these values ββin it $scope ?
I am thinking of a scenario where the HTML looks like this:
<div ng-controller="TestController"> <div ng-bind="title">Test Title</div> <div ng-bind="itemCount">33</div> <div ng-repeat="item in items"> <div ng-bind="item.title">Item 1 Title</div> </div> </div> <button ng-click="update()">Update</button>
And JavaScript looks like this:
function TestController($scope) { $scope.update = function() { console.log($scope.title); // Should log "Test Title" }; }
The idea is to allow the server to render HTML, which search engines can index , but have a version of the JavaScript model for the strong> model for manipulation via JS.
angularjs seo
Seb nilsson
source share