【发布时间】:2014-09-14 02:20:37
【问题描述】:
我正在尝试从这个 $scope 中创建一个简单的console.log():
<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>
这是我的 javascript 文件:
lima3app.controller("CustomerController", function($scope){
console.log($scope.customer);
});
但是日志返回我undefined。这有什么问题?
【问题讨论】:
-
$scope.customer没有在任何地方初始化,所以它应该是未定义的。在您在这些输入中键入内容后,它将开始有数据。
标签: angularjs logging console undefined