Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

AngularJS controllers

What is Angular JS controller?

Controllers are Central part in AngularJS, as name suggests controllers are in-charge of AngularJS application Data.

In short AngularJS application and application data is fully controlled by controller.

For Example for CRUD Application insert, update, delete all data actions performed by controller, controller also handle server communication.

Controller basics

1. An AngularJS controller is a JavaScript object containing attributes/properties and functions.
2. After using ng-app directive the ng-controller directive defines the application controller.
3. Controller will be a function that angular invokes.
4. Controller takes $scope parameter.
5. Attach model to &scope.


   <div ng-app>
        <!--application area-->
        <div ng-controller="MyTestController">
            <!--controller aria-->

Avoid Controllers to perform following actions (Suggestions from website)

Manipulate DOM: writing business logic in controller area is good practice, writing presentation logic may affect testability
Format input: use angular inbuilt form controls instead.
Data Filter: Use angular inbuilt filters to filter data.
Share code or state across controllers: Use angular services instead.

Manage the life: cycle of other components (for example, to create service instances).

Controllers are used to manipulate scope

Angular controller takes $scope as a parameter which Refers application module that is controlled and managed by controller.

Controller basic example with $scope parameter:

Following code subtracts user entered two numbers and displays result.

    <title>Angular JS Controller Example</title>
    <script src=""></script>
    <h2>AngularJS Sample Example</h2>
    <div ng-app="myCalApp" ng-controller="MyCalController">
         first Number: <input type="text" ng-model="FirstNumber"><br><br>
         Second Number: <input type="text" ng-model="SecondNumber"><br>
Subtraction of two numbers: {{FirstNumber-SecondNumber}}
        var app = angular.module('myCalApp', []);
        app.controller('MyCalController', function ($scope) {
            $scope.FirstNumber = 20;
            $scope.SecondNumber = 10;

Controller Example with External File and Method return:

Following code add entered two numbers and displays result.

    <title>Angular JS Controller</title>
    <script src=""></script>
    <script src="Scripts/TestController.js"></script>
    <h2>AngularJS Sample Example</h2>
    <div ng-app="myCalApp" ng-controller="MyCalController">
         first Number: <input type="text" ng-model="CalData.FirstNumber"><br><br>
         Second Number: <input type="text" ng-model="CalData.SecondNumber"><br>
       Addition of two numbers: {{CalData.Addition()}}


External “TestController.js” file code

var mainApp = angular.module("myCalApp", []);
mainApp.controller('MyCalController', function ($scope) {
    $scope.CalData = {
        FirstNumber: 10,
        SecondNumber: 20,
        Addition: function () {
            var CalculatorObject;
            CalculatorObject = $scope.CalData;
            return CalculatorObject.FirstNumber + CalculatorObject.SecondNumber;


धन्यवाद मित्रानो ... 

Agile Testing

Agile Software Testing

In this article I will explain in detail what is agile testing and advantages using agile testing.

Definition (Reference Wikipedia)

Agile testing is a software testing practice that follows the principles of agile software development. Agile testing involves all members of a cross-functional agile team, with special expertise contributed by testers, to ensure delivering the business value desired by the customer at frequent intervals, working at a sustainable pace.


Agile, as its name suggests, simply proposes to be a faster, more priority & risk focused, and more flexible, adaptable, and efficient way of conducting the complicated business of software production.  And, of course, it is not without its critics.

In the agile approach:

      => Testing and coding are done incrementally and interactively

      =>  Developers and testers should always meet and compare notes daily

      =>  Building up each feature until it provides enough value to release to production

      =>  Requires a depth of continuous collaboration between stakeholders- mangers, developers, testers and customers throughout the production process  

      =>  Reducing the need for robust testing teams

      =>  All types of testing covers

Advantages of Agile Testing: 

1.  Agile Testing Saves Time and Money.

2.  Less Documentation.

3.  Regular feedback from the end user.     

4.  Daily meetings can help to determine the issues well in advance.

In the usual waterfall model the sequential phases are: 

As you can see in the diagram above, in a waterfall process the “design” and “implementation” stages exist prior to, and distinct from, the “verification” and “maintenance” stages.  This split between software developers and software testers, positioning them as separate entities at different points along a production cycle, is one of the fundamental problems that Agile seeks to resolve.


Agile Scrum Process:

In the Scrum method of agile software development, work is confined to a regular, repeatable work cycle, known as a sprint or iteration. Scrumsprints used to be 30 days long, but today many teams prefer shortersprints, such as one-week or two-week sprints.
The sprint backlog is a list of tasks identified by the Scrum team to be completed during the Scrum sprint. During the sprint planning meeting, the team selects some number of product backlog items, usually in the form of user stories, and identifies the tasks necessary to complete each user story.
The Scrum Master is to constantly refine the schedule and direction and keep the team
on track.

Advantages over classic waterfall model:

1.  Scrum relies on more frequent touch points between developers and testers,

Testers and BAs, and BAs and Developers to make sure any changes are

Properly communicated.

2.  Daily standup calls keeps activities aligned, remove obstacles if any team member facing.

3.  Knowledge sharing is better in this process.

4. Strong project management keeps team on track and active.

Agile is constantly evolving. Today there are emerging methodologies like BDD, TDD, ATDD, Kanban and many more.

Functional Testing

In this tutorial I will explain functional testing with sample example.


Functional testing means testing the application against business requirements, client requirements.

In Detail:

Functional Testing:

  •     is a quality assurance (QA) process
  •     is the testing technique which used to test features
  •     It test functioning of the system / software


The registered user should be able to login to the Leave web application, only admin users
Has access for administration panel. General user can only apply for leave and check their leave details.
Master users (Manager) can approve/reject general users (Employee) leaves.


The functions are described in the FRS or SRS documents

Major Functional Testing Techniques are:

1. Unit Testing 
2. Integration Testing
3. System Testing  
4. Regression Testing
5. Acceptance Testing
6. Smoke Testing
7. Sanity Testing
8. Exploratory Testing 
9. Ad hoc Testing
10. Localization Testing
11. Interface Testing
12. Usability Testing
13. Globalization Testing