【发布时间】:2018-09-10 09:21:55
【问题描述】:
我不明白为什么它会在输入字段中显示函数?我只是想输入一个名称并将其显示给用户。
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;
}
};
});
【问题讨论】:
-
因为你已经用你的 fullName 函数覆盖了你的学生对象的属性 fullName。
标签: javascript html angularjs input output