저는 Angular JS에서 매우 작은 어플리케이션을 사용합니다. 더 큰 레일 애플리케이션에 배치되었지만 너무 많은 상호 작용을 보지 못합니다. 각 응용 프로그램은 사용자가 범주 그룹과 상호 작용할 수 있도록합니다. 한 쉽게 :각도 js에서 바인딩 손실 (클릭 후) 작은 예제
var angular_app = angular.module('angular_app', []);
angular_app.config(['$httpProvider', function($httpProvider, $cookieStore) {
//Protection
}]);
angular_app.controller('CategoriesController', function ($scope, $http) {
$scope.isEditing = false;
$scope.categoryName = '';
$http.get('/api/categories').success(function(data) {
//We use this to data-bind with the HTML placed below
$scope.categories = data;
});
$scope.addNewCategory = function() {
...
}
$scope.editCategory = function(index) {
if (!index)
return;
var selectedCategory = $scope.categories[index];
// With ng-show, we make visible the part of the UI
// that should be used for editing
$scope.isEditing = true;
}
$scope.cancelEditCategory = function() {
$scope.isEditing = false;
}
$scope.deleteCategory = function(index) {
...
}
});
angular.element(document).ready(function() {
angular.bootstrap(document, ['angular_app']);
});
아이디어는 정보가 목록에 표시되어 있는지, 우리는 사용자가 그 변경 사항을 수행 할 것입니다 UI의 다른 부분을 볼 수있는 '편집'버튼이 있습니다.
<div ng-controller="CategoriesController">
<div ng-show='isEditing' class="popup_menu">
DIV FOR EDITING
</div>
<ul>
<li ng-repeat="category in categories">
<a href="#" ng-click='deleteCategory($index)'>[X]</a>
<a href="#" ng-click='editCategory($index)'>[E]</a>{{ category.name }}
</li>
</ul>
<input type="text" id="categoryTextBox" ng-model="categoryName"/>
<button id="submit" ng-click='addNewCategory()'>New category</button>
</div>
내가 편집 버튼을 클릭하고있어, 사용자 인터페이스의 해당 부분을 볼 얻을 수 있지만, 단지 그 후, 어떤 일이 발생하고 목록을 렌더링해야 UL은 완전히 바인딩, 단지 보여주는 무언가를 푼다 같은 :
[X] [E]{{ category.name }}
것은 그것이 보여주는해야하는 경우 :
[X] [E]computer science
[X] [E]politics
[X] [E]news
(나는 범위에있는 것입니다). 클릭 후 몇 번 발생합니다 (몇 초 동안 작동합니다). 콘솔에 오류가 없습니다., 다른 라이브러리와의 상호 작용은 없습니다 (내가 볼 수있는 한).
감사합니다.
오류는 브라우저 콘솔 로그를 참조하십시오. – Chandermani
감사하지만 오류 로그가 비어 있습니다. – IoChaos