컨트롤러의 다른 함수간에 변수를 전달하려고합니다.각도 전달 변수
이HTML :
<table class="flat-table">
<tr>
<th>User</th>
<th>Comment</th>
<th>Date</th>
<th>Controls</th>
</tr>
<tr ng-repeat="doc in guest.docs">
<td>{{doc.value.user}}</td>
<td>{{doc.value.comment}}</td>
<td>{{doc.value.date}}</td>
<td>
<img class="controls" src="styles/delete.png" ng-click="guest.delete(doc.id)" title="Delete">
<img class="controls" src="styles/edit.png" ng-click="guest.visible = true; guest.editBox(doc.id)" title="Edit">
</td>
</tr>
</table>
<div id="signCon">
<form name="addForm" ng-submit="guest.add()">
<textarea type="text" ng-model="guest.signature.comment" id="comment" placeholder="Enter a comment?!" required></textarea>
<br/>
<input type="submit" value="Sign!">
</form>
</div>
</div>
<div id="editCon" ng-show="guest.visible === true">
<h1>Edit</h1>
<p>Here you can alter your comment.</p>
<form name="editForm" ng-submit="guest.submitEdit(guest.editBox.signature)">
<textarea type="text" ng-model="guest.submitEdit.comment" required></textarea>
<br/>
<input type="submit" value="Edit!">
</form>
</div>
ANGULAR :
이this.editBox = function(id) {
var that = this;
this.id = id;
this.signature = {};
if(self.visible) {
$http({
url: 'http://ip:5984/guestbook/' + this.id,
method: 'GET',
withCredentials: true,
headers: {
'Authorization': auth_hash(UserService.get().username, UserService.get().password)
}
}).success(function(data, status, headers, config) {
that.signature = data;
console.log(that.signature);
}).error(function(data, status, headers, config) {
console.log("error!")
});
};
};
this.submitEdit = function(signature){
var self = this;
this.comment = '';
this.signature = signature;
console.log(this.signature);
};
아이디어는 그 편집 이미지에 사용자가 클릭 새 창이 나타납니다 때 여기에 내가이 일을 사용하고있는 코드는 그들은 새로운 코멘트를 입력하고 다시 제출할 수 있습니다. 창이 올바르게 표시되고 개체를 올바르게 당길 수 있습니다. submitEdit 함수를 호출하려고 할 때입니다. 서명 변수를 통과하지 않는 것 같습니다. 이 일을 제대로하고 있습니까?
전체 컨트롤러 코드를 게시 할 수 있습니까? –