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