0

I am testing AngularJS as follow.

Script.js

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


myApp.controller("myController", function ($scope){
    var employee = {
        firstName = "Test",
        lastName = "Name",
        gender = "Male"        
    };
    $scope.employee = employee;    
});

index.html

<html ng-app="myModule">
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="Scripts/angular.min.js" type="text/javascript"></script>
        <script src="Scripts/Script.js" type="text/javascript"></script>
    </head>
    <body ng-controller="myController">
        <div>  
            {{ employee.firstName }} 
        </div>
        <div>  
            {{ employee.lastName }} 
        </div>
        <div>  
            {{ employee.gender }} 
        </div>

    </body>
</html>

When I run the program, I just see as

{{ employee.firstName }}
{{ employee.lastName }}
{{ employee.gender }} 

I don't see in correct format. What could be wrong?

Thanks

1
  • First thing you should have done is look for the errors in your browser's console Commented Oct 13, 2016 at 2:39

1 Answer 1

2

There is an issue in the way you are assigning values to the employee object , it should be like this,

myApp.controller("myController", function ($scope){
    var employee = {
        firstName : "Test",
        lastName : "Name",
        gender : "Male"        
    };
    $scope.employee = employee;    
});

DEMO

Sign up to request clarification or add additional context in comments.

4 Comments

Nope, still the same.
Yes yours is working. Yours and mine not different. Why mine is not working?
@batuman chec firstName : "Nyan", you are assigning with an =

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.