How To render HTML in Handlebars.js

No comments
Problem-> If you have stored HTML in Database and want to render with it TAGs like <Pre> tag works so you have to do one step is that...?

Ans ->  use {{{threeCurlybraces}}} insted on two.

it is the same in vanilla Mustache 

No comments :

Post a Comment

How do I pass a variable to child page in ionicframework ?

No comments

Problem - > Once I've faced this problem, I've menu created with a list and ng-repeat.
I want to use a variable from an array of objects to create a child menu on another page (like in the Tabs starter Chat tab) but was using ui-sref and I won't work out at the I got solution is that -

Ans->

1- first go to app.js file and define this line params: { varTest: null } varTest is variable which takes your data object and deliver you on the next page .

.state('app.childPageName', {
        url: '/test/childPageName',
        params: { varTest: null },
        views: {
            'menuContent': {
                templateUrl: 'test/childPageName.html',
                controller: 'childPageNameCtrl'
            }
        }
    })

within ng-repeat sectioin ( or within ng-repeat DIV)
use this ui-sref="app.PageNameYouWnatToSendObj ({varTest:ngRepeatObj})"

now go to the controller where you have sent the object ( PageNameYouWnatToSendObj ) and receive the object like this --- >>

$scope.var = $stateParams.varTest;
console.log($scope.var);

• don't forget to inject $stateParams as a dependancy.
• varTest is the name of variable which will carry your object from one page to another page.
•console.log will print the complete object which you have sent form last page.

feel free comment below if you have any question regarding that.

No comments :

Post a Comment

Datatables Server Side Implementation with Nodejs and MongoDB

No comments
How to implement server side Datatables processing using Node-js and MongoDB (ExpressJs) 

Something you should kept in mind is that -
1- Add Datatables CDN or offline link.
2- Try to implement client side Datatables first.(This is server side Implementation and to be used if your have more than 1000 record.)  

• Now this is working Code.....
• this code to be used on client side (HTML) page

$('#example').dataTable({
processing: true,
destroy:true,
autoWidth:false,
sAjaxDataProp: 'data',
ajax:{
url: "/getData",
type: 'POST',
data: {"id":id,"product":prdMain},
dataSrc: ""
},
columns: [
{ data : "job_name" },
{ data : "product" },
{ data : "test_plan" }

] ,"fnRowCallback":function( nRow, aData, iDisplayIndex, iDisplayIndexFull ){

var dat1 = '<div >'+aData['job_name']+'</div>';
var dat2 = '<div >'+aData['product']+'</div>';
var dat3 = '<div >'+aData['test_plan']+'</div>';
$('td:eq(0)', nRow).html(dat1);
$('td:eq(1)', nRow).html(dat2);
$('td:eq(2)', nRow).html(dat3);
}
});


• Nodejs Controller code 


router.post('/getData', function(req, res){    
     obj.getData(function (err,data) {        
        if (err) throw err;
        else {
         res.send(data); //send as it is to client page//
         };
    }) 
});

Models Code 

• Fetching the data from MongoDB.

module.exports.getData= function (callback) {
     Data.find({},callback);  //.Find is Used to get all data.
}


Note - This is not for beginners so I have skipped the basic things like exports and injections as this blog is dedicated to programmers so if you wish to continue with this post you must know basic things and in case you still face any issue kindly comment bellow.



No comments :

Post a Comment