2
HTMLAngularJS替換列表時,點擊NG-點擊NG-重複
<ul class="feature-list-1">
<li ng-repeat="(key, value) in features" ng-click="featureSelect(key)">{{key}}</li>
</ul>
ANGULARJS
$scope.features =
{
"administrative": [
{ id: 1, val: "Country"},
{ id: 2, val: "Province"},
{ id: 3, val: "Locality"},
{ id: 4, val: "Neighborhood"},
{ id: 5, val: "Land parcel"}
],
"landscape": [
{ id: 1, val: "Man made"},
{ id: 2, val: "Natural"}
]
};
$scope.featureSelect = function(i) {
$('.feature-list li').remove();
$.each($scope.features[i], function(i,v){
$('.feature-list').append('<li>'+v.val+'</li>');
});
}
我學習AngularJS什麼,我想在這裏做的是當初始列表中的某個項目被點擊時,它將是administrative
或landscape
,我希望列表清除,然後用只有Angular的嵌套數據替換值。在示例Plunker我已經使用jQuery替換內容,並且我知道它效率不高,因爲我希望能夠正確地執行此操作。
例如。如果點擊landscape
名單將清除,並通過Man made
和Natural
謝謝!有一些修補我能夠得到它的工作。非常感激! – ngplayground
@Donald - 沒問題!一定要標記答案,如果它適用於亞! – tymeJV