Я новичок в AngularJs и еще не понял все, у меня много вопросов, и это следующее:
Это мой html:
<ion-view view-title="Account Fixer">
<ion-content class="padding">
<div class="list">
<label class="item item-input item-stacked-label">
<span class="input-label">IrId</span>
<input type="text" placeholder="irid" value="{{irid}}" disabled>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Email</span>
<input type="text" placeholder="Enter New Email" value="{{email}}">
</label>
<button class="item button button-block button-positive" ng-click="postForm()">Fix Issue</button>
</div>
</ion-content>
</ion-view>
Это мой контроллер:
.controller('TestCtrl',function(Test,$scope, $http, $stateParams){
$scope.email = Test.get('AB12345').email;
$scope.irid = Test.get('AB12345').irid;
//I want to hit this during onclick ONLY
$scope.postForm = function(dataForm){
var encodedString = 'action=' +
encodeURIComponent("QA_fixEmail") +
'&irid=' +
encodeURIComponent(Acct.acctData().irid) +
'&email=' +
encodeURIComponent(dataForm.email) +
'&password=' +
encodeURIComponent("abcd1234");
$http({
method: 'POST',
url: 'someservice',
data: encodedString,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
})
.success(function(data,status){
console.log(status);
})
.error(function(data, status){
console.log(status);
})
}
})
В: Возможно ли, чтобы [ударить функцию] во время onclick?
A: Да, конечно. Просто используйте ngClick
Вот некоторые примеры:
Обратите внимание, что в одной ссылке используется ng-click
, а в другой ссылке используется ngClick
. Они эквивалентны: