Skip to main content

Posts

Showing posts from May, 2015

How to inject to services, factories and providers?

Hello everyone, today I am going to share the very interesting when we play with services, factory and provider in angular. I notice an interesting point when I playing with providers . Here highlight the visibility of injectable. The services, factory  and provider are injectable but  the injectable is different for provider than from services  and factory. I am going to a scenario, if you declare a constant(i.e. like angular.constant( 'baseUrl' , 'http://localhost:9669/' )), here you can inject into services, factories and providers. But when you declare a value (i.e. like angular.value( 'user' , {id: 'uid9669'} )), here you can inject into services and factories but not provider.  The provider creating a $get function and then you can  inject it. live demo click on link  http://embed.plnkr.co/0EANoZ/preview For example over the injecting as given below. AngularJs code sample var app = angular.module( 'userApp'

What is MongoDB and Why we use MongoDB?

The MongoDB  is now most popular cross platform NoSQL  open source database management system. The MongoDB is written using the C++ language and developed by 10gen but now it's called MongoDB Inc. The MongoDB  is document oriented database and its store the data in document with JSON format. i.e.     {         UserId: 001,         UserName: 'Anil Singh' ,         EmailID: 'anil@gmail.com' ,         ContactNo : '9016615587',           OtherDetail: [            {                Qualification: "MCA" ,                WorkingArea: 'IT Software' ,                Comments: 'put anything else...'            }]     } In the JSON  document, Table name called collection, row called document, column name called Field, Joins called  linking etc. The MongoDB is supported to most languages like Java, c#, JavaScript etc. and its run on the window, Linux, Mac etc. operating systems.    Wh

What are constant and value in angularjs?

Hello everyone, I am going to share to constant vs.value  in angular, This is the most important part of angular and the best practice to use constants and value in angular apps. The angular support to global constant  and value, using the constant and value you can configure your constants and its values. The values can be injected and can't injected  as per you requirement. When you want to inject your values that time use angular value and otherwise use to angular constant. The constant value never change and access the value from anywhere and anytime in the apps. The value and constant  both are same but the value of values can be change anywhere and anytime in the apps. This is the main difference over the constant and value in angular. Example over angular value Example 1. storing the single value as given below // storing a single value var app = angular.module( "valueApp" , []); app.value ( "userId" , 0); //Here inje

How to ng-repeat through returned items by calling a function on ng-init?

Click for Punker live demo The live demo example code (HTML + AngularJs) as given below < html > < head >     < title > How to Loop through itemsreturned by a function with ng-repeat? </ title >     < script src ="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></ script >     < script >         var parentApp = angular.module( "myApp" , []);         parentApp.controller( "MyController" , function ($scope) {             var userDetail = {                 ID: 1,                 Name: 'Anil Singh' ,                 Age: 30             };             $scope.getUsers = function () {                  return userDetail;             }         });     </ script > </ head > < body ng-app ="myApp">     < h2 > User Details </ h2 >     < div ng-controller ="MyController">         <