Ich versuche, eine einfache console.log()
von diesem $ Umfang zu machen:
<div ng-controller="CustomerController" id="customer-block">
<h3>Customer Information</h3>
<div class="col-md-4">
<label>Address 1:</label>
<input type="text" ng-model="customer.address1" class="form-content"
id="customer-address1" />
</div>
<div class="col-md-4">
<label>Address 2:</label>
<input type="text" ng-model="customer.address2" class="form-content"
id="customer-address2" />
</div>
<div class="col-md-4">
<label>City</label>
<input type="text" ng-model="customer.city" class="form-content"
id="customer-city" />
</div>
</div>
Dies ist mein Javascript-Datei:
lima3app.controller("CustomerController", function($scope){
console.log($scope.customer);
});
Aber Das Protokoll gibt mir undefined zurück. Was stimmt damit nicht?
Dies ist plunkr: http://plnkr.co/edit/MU2i46o03bs22Jwh6QIe
Der '$ scope.customer' wird nirgends initialisiert, also sollte es undefined sein. Es beginnt Daten zu haben, nachdem Sie etwas in diese Eingaben eingegeben haben. – runTarm