Question

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.

Was it helpful?

Solution

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(']]');

});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top