Javascript handles function and variable declartions quite differently and you must have got stuck in one of the awkard scenarios due to it. First of all, you should be familiar with Scoping in JavaScript. If you are, then you would know already that JavaScript only has function scopes and no block scopes. [js] var a = 'hello'; ...
In AngularJS, we can easily write our own custom directives to achieve required functionality. There are certain attributes which we provide in directive definition like restrict , scope , template, link, transclude etc. There is one more attribute named : require , which gives us the liberty to include another directive and inject...
In our previous post, we saw how simply we could use the free text search feature from MongoDB. In continuation to that, in this post we would be looking at how can we create multiple text indexes and understand how actually the things work. Document Scoring MongoDB assigns a score to each of the document that contains the search term...
MongoDb introduced free text search beta in its v2.4 but it was in experimental phase. In v.2.6, MongoDb has finally made its free text search (the most requested feature) production ready. In this post, we will have a look at how can we use this pretty useful feature that MongoDb offers us. To enable Free text search, Mongodb...
PhantomJS is used to emulate browsers through command line, for generating PDFs, web page manipulation, headless testing and much more interesting stuff. Npm provides us a module called "node-phantom" which helps us to use PhantomJS in our NodeJS application in a non-fussy way. A prerequisite for using this module is, you must have...
In my Angular project, I came across a situation where i had to render some html markup, but the tricky thing was, the markup was contained in some angular scope variable. And when outputting it, it just printed out the html markup as basic text. A quick Google search informed me about the directive ng-bind-html and...
For building an application with user friendly and consistent UI, we generally use the concept of "master page" and "layouts", so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and footer static...
In our node js application, we can use variety of templating engines like "jade" , "ejs", "mustache" etc. Dust.js is an asynchronous templating engine which can be used both on server side as well as client side and provide easy caching with high performance. In my previous blog on EJS as a templating engine, i have mentioned how we...
AngularJS, Front End Development
While using AngularJS, you will usually come across this situation when you want to copy one object to another object. In such case you will have only two solutions: angular.copy() or angular.extend(). Lets see how these solutions work. 1. angular.copy(source, destination) : It creates a deep copy of source object or array and...
EJS as the name implies embedded JavaScript, is a JavaScript templating library used to render html code along with JSON data in an easy and clean way. In a Node.JS application(here we are using an express application), you need to set the value of 'view engine' parameter to 'ejs'. [js] var app = express(); app.set('view engine',...
AngularJS, Front End Development
While using AngularJS, we come across situation in which we want to display some data in certain format or some specific condition to be applied on the data. In this case, filters comes to rescue. We can define our custom filters and return filtered data in whichever way we want to display it. Lets learn it through an example: ...
We can create collections in mongoDb on which we can apply size limit. These special type of collections are called Capped Collections. These are a kind of circular queues, in which if allocated size limit is reached, it makes space for new documents by overwriting the oldest documents in the collection. How to create Capped...