Why AngularJs Controller is not Working proper?

Total Post:13

 1542  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>
You are entering: {{employee.fullName()}}

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

Thank you in Advance:

  1. Post:16

    Re: Why AngularJs Controller is not Working proper?

    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 Apr-09-2018 02:23:43 AM