我试图让引导弹出窗口中的内容在用户在电子邮件文本框中键入内容时进行更改。似乎 ng-change 没有进入 method updateToolTip()
。我是 AngularJS 的新手。任何建议表示赞赏。
html页面
<div ng-controller="LoginController">
<for name="form" ng-submit="login()">
<input type="email" name="email" ng-model="user.email" value="{{user.email}}" ng-change="updateToolTip()" popover="{{emailMessage}}" popover-trigger="focus" popover-placement="right" required>
<button class="btn btn-lg btn-primary btn-block" type="submit" ng-disabled="form.$invalid">Sign in</button>
</form>
</div>
js
var loginModule = angular.module('loginModule', ['ui.bootstrap']);
// Controller for the login page
loginModule.controller('LoginController', ['$scope', '$http', function($scope, $http) {
$scope.emailMessage = 'test';
$scope.updateToolTip = function() {
$scope.emailMessage = 'asdfsadf';
console.log();
console.log(' inside function');
if($scope.user != null) {
console.log('user not null');
if($scope.user.email.$dirty && $scope.user.email.$error.email) {
console.log('email dirty and error');
$scope.emailMessage = 'Invalid Email!';
} else if($scope.form.email.$dirty && $scope.form.email.$error.required) {
console.log('emaildirty and required');
$scope.emailMessage = 'Email Required';
}
}
}
}]);