0

I'm developing an app using angularjs with nodejs and dustjs.

What i'm trying to achieve is like during the page refresh pass the data like

res.render('index', {names : [{name:"name1"},{name:"name2"}]});

and dustjs should able to render

{#names}<li>{name}</li>{/names}

how can i use angular js ngrepeat for subsequent actions in the page.

As of now i'm making a http request get the json and render page fully in client side.

<li ng-repeat="myname in mynames>{{myname.name}}</li>

I don't prefer to save my data as JavaScript variable, which is readable through source.

Just want know if somebody done something like this.

tomalex
  • 1,233
  • 6
  • 17
  • 40
  • I found similar post here http://stackoverflow.com/questions/11838639/html-template-filled-in-server-side-and-updated-client-side?rq=1 – tomalex Mar 18 '14 at 23:07
  • It's atypical to do server side rendering of pages when using a SPA framework that includes binding and templates and such dustjs seems like "double duty", is there some advantage you see with using it? – shaunhusain Mar 18 '14 at 23:28
  • I'm using krakenjs.com for my application, were default template is dustjs, anyhow i will have some template engine at the server side. – tomalex Mar 19 '14 at 02:30

1 Answers1

0

I done it in a hackish way to implement this, not a suitable solution.

I used ng-if of angularjs to do this

var mynames = [{name:"One"},{name:"Two"}]

<div ng-if="!mydata">
     {#mynames }
        <div>{name}</div>
     {/mynames }
</div>


<div ng-if="mydata"> 
     <div ng-repeat="myname in mynames">[[myname.mynames]]</div>
</div>

i'm using square brackets for angularjs as there was some conflict with dustjs which was fixed using below code

angular.module('myapp').config(function($interpolateProvider){

    $interpolateProvider.startSymbol('[[');
    $interpolateProvider.endSymbol(']]');

});
tomalex
  • 1,233
  • 6
  • 17
  • 40