Home > DeveloperSection > Forums > Why AngularJs Controller is not Working proper?
Linda Perla
Linda Perla

Total Post:13

Points:93
Posted on    March-21-2015 6:48 AM

 Angular JS Angularjs Controller 
Ratings:


 1 Reply(s)
 655  View(s)
Rate this:

Hi I’m new new in Angularjs library I’m begin to learn AngularJs Controller but my Controller is not work

My AngularJs Controller Code:

mainApp.controller('employeeController', function ($scope) {

        $scope.employee = {

            firstName: "Kamlakar",

            lastName: "Singh",

            fullName: function () {

                var studentObject;

                employeeObject = $scope.employee;

                return employeeObject.firstName + " " + employeeObject.lastName;

            }

        };

    });

My AngularJs Html Code:

<div ng-app=" " ng-controller="employeeController">

 

Enter first name: <input type="text" ng-model="employee.firstName"><br><br>

Enter last name: <input type="text" ng-model="employee.lastName"><br>

<br>

You are entering: {{employee.fullName()}}

</div>

Where is problem I can’t understand please solve my problem as soon as possible.

Thank you in Advance:



Jessica James
Jessica James

Total Post:16

Points:114
Posted on    March-21-2015 7:23 AM


You have missed the code for initialize angularjs application code


Try this code:

Controller Code:

This code write first line

var mainApp = angular.module("mainApp", []);

Html Code:

<div ng-app=" " ng-controller="employeeController">…</div>


Modified On Mar-18-2016 11:19:25 PM

Don't want to miss updates? Please click the below button!

Follow MindStick