0
我有一个带有输入文本字段的页面html,并且此输入文本由复选框控制。当复选框为false时,它会出现,当复选框为真时,输入文本将显示。 这是非常好的工作,但是当我尝试获取用户在此字段中输入的值时,controllerJS无法获取它。使用控制器无法从html文件中获取值Angularjs
我已经使用这个代码:
<div class="form-group">
<label>
<input
type="checkbox"
ng-model="checkedSubject"
>
<img src="../../innerPages/gmailChannel/email-text-search.png" height="30" width="30"/> Email content query:
</label><br/>
<textarea
class="form-control animate-if"
ng-if="checkedSubject"
rows="5" id="subjectReceive" placeholder="Insert here some text to filter the emails"
ng-model="gmailinput.subjectReceive" name="subjectReceive" ng-disabled="!checkedSubject"
maxlength="100%" ng-trim="false"
></textarea>
<span>{{500 - gmailinput.subjectReceive.length}} left </span></div>
我已经使用这个代码传递变量
<div>
<a type="submit" class="btn btn-danger pull-left" href="#allTriggers" >Cancel</a>
<a href="#createRecipeAction" ng-disabled="!checkedSubject" type="submit"
class="btn btn-primary pull-right btn_next3" ng-click="triggerGmail(gmailinput)" >Next</a>
</div>
这是我的控制器:
ftttApp.controller('GmailTriggerController', ['$scope', '$rootScope', '$routeParams', '$http', '$location',
function ($scope, $rootscope, $routeParams, $http, $resource, $location) {
$scope.triggerGmail = function(user)
{
alert(user.subjectReceive);
};
}]);
我的目标是打印,但我无法做到。
我事先感谢您的帮助。
你的ng模型是'gmailinput.subjectReceive'。因此,你的提醒应该是alert($ scope.gmailinput.subjectReceive);'。 –
这是行不通的。我改变了我的警报,我的浏览器的控制台说:“错误:undefined不是一个对象(评估'$ scope.gmailinput.subjectreceive')” – snorlax