AngularJs Logging

Some time ago i look to many approaches about organization concepts and patterns clean code for AngularJs. In result i want to put in next articles code from lessons of John Papa and Ari Lerner - NG-Book - 2013. More than, i want to separate in pieces all code, to not mix all these things in one and give to see more clearly how works they separately.

When i start to make some program i love to start from small and easy thing to more complicated. So for the first i will configure the logging .

I don’t know how you but i like to see in images all things, i hope you will not be frustrated if i will use images.

Step 1. I add the logger folder like below and add script “logger.module.js” . In this file usually we just initialize new module, we can intuitively see from name of file.

First Image

 

Code: Read code

Angular Code

Step 2. Add logger

Logger

Code: Read code

Step 3. Use code

Logger

Code: Read code

 

Source of code

AngularJs - Request parameter from url using $routeParams

Goal: How to get parameters from url using $routeParams for Single Page Web Application like “http:/MyWebApplication/#/updateTemplate/1”

Introduction: Sometimes we have list of elements. And probably we need to edit some element from this list. After few more research, i create a small example for this approach.

Keys:

$routeParams - allows you to retrieve the current parameters from url

Example:

1. Create route configuration and include templates for “ToDoList” and “UpdateToDoElement”.

RouteConfiguration

2. Create controllers and business logic for getting id from url request.

Controller Configuration