【发布时间】:2014-08-21 02:16:26
【问题描述】:
我是 angularjs 的新手,我遇到了麻烦,
我有这样的 html:
<section class="content" ng-app="offer">
<div ng-controller="OfferController">
...
<input name="Attachment" type="file" class="file_up" onchange="angular.element(this).scope().change(this)" ng-model="Attachment" />
<span>{{Attachment}}</span> //i can't get it
...
</div>
</section>
和脚本:
var myApp = angular.module('offer', []);
myApp.controller('OfferController', ['$scope', function ($scope) {
$scope.change = function (element) {
if (element.files.length > 0) {
$scope.Attachment = element.files[0].name;
}
else {
$scope.Attachment = "";
}
console.log($scope.Attachment); // I can get changed value in console
}
}]);
图片:
我可以在控制台中获取更改的值,但是当输入的值更改时,我不能进入 html 端。非常感谢您的帮助。
【问题讨论】:
标签: javascript angularjs