0

i cannot find a problem here, why i cant see the value in the

HTML:

'<div ng-app="BusinessinfoModule" ng-controller="BusinessinfoController" 
                          <label>Your Business Name</label>
    <input type="text" class="form-control"  name="bussiness" ng-model="bussiness" ng-maxlength="100" required>
</div>'

and the controller:

angular.module('BusinessinfoModule', [])
  .controller('BusinessinfoController', function($scope) {
    $scope.business = 'aaa';
  });

Here the codepen: http://codepen.io/anon/pen/GJggeE

6
  • What is this? Put proper code. Commented Apr 25, 2015 at 7:27
  • your controller code is missing. Also, for proper formatting, just paste the code into the textfield, highlight the code, and press control + k (or click on the code button). Commented Apr 25, 2015 at 7:28
  • sorry, here the better now Commented Apr 25, 2015 at 7:28
  • did you add the reference to angular js script ? Commented Apr 25, 2015 at 7:31
  • 2
    Your ng-model name is different from that in controller. bussiness & business, is that a typo? Commented Apr 25, 2015 at 7:51

1 Answer 1

1
<div ng-app="BusinessinfoModule" ng-controller="BusinessinfoController" >

    <label>Your Business Name</label>
    <input type="text" class="form-control"  
     name="bussiness" 
     ng-model="business " //ng-model which binds your controller scope to ui.
     ng-maxlength="100" 
     required/>

</div>





angular.module('BusinessinfoModule', [])
  .controller('BusinessinfoController', function($scope) {
    $scope.business = 'aaa';
  });

https://jsfiddle.net/ncoxq6zf/

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

2 Comments

When controller gets executed it uses business scope which has 'aaa' value and if you look at in html the scope of your controller named BusinessinfoController ,it is defined for whole div. so your ng-model binds scope value to ui. (it plays two way Binding)
Open your browser console and let me know which errors occur?

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.