Posts

Showing posts from March, 2016

Parsing html tags through angular js

Here is an easy way of parsing html from database in angular js.  Download  ng-htmlCompiler.js from Github : https://github.com/rroxysam/ng-htmlCompiler.  Include ng-htmlCompiler.js file in your layout & then  u se ng-htmlCompiler in your angular module as : angular.module('app_name',['ng-htmlCompiler']); And then in your view template use compile directive in your html element given below.  compile = "your-data-variable" This directive will work well in single element & also with angular ng-repeat. For Demo visit :-  https://plnkr.co/edit/leooiVyTKC9m6eR8cqPN?p=preview

Type casting to ObjectId in nodejs using mongoose

Sometime, we are unable to fetch the result from database as the object id coming from our request is of  String  type. So for this case, we can type cast our string parameter into ObjectId easily. var reqId = "any_string_objectId";  // coming from http request var ObjectID = require('mongodb').ObjectID;  requiring mongodb driver reqId = new ObjectID(reqId);  // output ObjectID NOTE :  Mongoose automatically typecast string id into objectId during query execution but sometime we have to manually convert into ObjectID.