我不明白为什么它会在输入字段中显示功能?我只是尝试输入一个名称并将其显示给用户。
HTML:
<div ng-app = "mainApp" ng-controller =
"studentController">
<tr>
<td>Enter full name:</td>
<td><input type = "text" ng-model =
"student.fullName"></td>
</tr>
<tr>
<td>Name in Upper Case:</td>
<td>{{student.fullName() | uppercase}}</td>
</tr>
</div>
JAVASCRIPT:
var mainApp = angular.module("mainApp", []);
mainApp.controller('studentController',
function($scope) {
"use strict";
$scope.student = {
fullName: function() {
var studentObject;
studentObject = $scope.student;
return studentObject.fullName;
}
};
});
答案 0 :(得分:0)
因为要使用函数作为模型进行数据绑定的两种方式。当绑定从视图到范围时,输入元素将为fullName分配一个字符串