JSBin中的此代码:
我想使用AngularJS模型
在需要输入电子邮件时隐藏或显示星号已经检查了这些:
HTML
<body ng-app="myApp">
<form ng-controller="controllerUser">
<div class="row">
<div class="rt-grid-2 label-form">
<span class="required">*</span>
<span>User Type</span>
</div>
<div>
<select id="userType" name="userType" ng-model="userType" ng-required="true">
<option value=''>select</option>
<option value='personal'>Personal</option>
<option value='company'>Company</option>
</select>
<div class="errorMessage"></div>
</div>
</div>
<div class="row">
<div class="rt-grid-2 label-form">
<span class="required" ng-hide="email.required">*</span>
<span>E-mail</span>
</div>
<div>
<input type="email" id="email" name="email" ng-model="email" ng-maxlength="50" ng-required="isCompany()">
<div class="errorMessage"></div>
</div>
</div>
<input type="submit" value="Send">
</form>
</body>
的Javascript
var myApp = angular.module('myApp', []);
myApp.controller('controllerUser', ['$scope', function ($scope) {
$scope.isCompany = function () {
return $scope.userType == 'company';
};
}]);
我尝试了不同的形式但是没有工作。