1
<!DOCTYPE html>
<html>

 <head>

          <title>ggl</title>
          <link rel="stylesheet" href="css/bootstrap.css">
          <link rel="stylesheet" href="css/style.css">
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width">
 </head>
 <script src="js\angular.min.js"></script>
 <script>
 function Customer($scope){
   $scope.CustomerName="bob";
   $scope.CustomerCode="200";
 }
 var myApp = angular.module("myApp",[]);
 myApp.controller("Customer", Customer);



 </script>
 <body>

   <div id="CustScreen" ng-controller="Customer">
     Customer Name :-<input ng-model="CustomerName"type="text" id="CustomerName">
     Customer Code :-<input ng-model="CustomerCode"type="text" id="CustomerCode">
     <div id="divCustomerName">{{CustomerName}}</div>
     <div id="divCustomerName">{{CustomerCode}}</div><br/>
   </div>


 </body>
 </html>

The outcome when I run the program is that it prints {{CustomerName}} in the div and not the expected input name. I am unsure if it is a problem with the code itself or the linking I have made.

2 Answers 2

2

First of all, your script is between the <head> and <body> tag, but that's probably not the issue here. The issue is most likely because you forgot to add

ng-app="myApp"

on one of your root elements e.g. <html ng-app="myApp">.

Without that attribute, angular doesn't know where to start bootstrapping the application.

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

Comments

0

You havent added ng-app directive in the HTML. Replace <html> as <html ng-app="myApp">

Comments

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.