0
我如何使這個工作與AngularJS?將此列表留在左側,並且需要更改此列表中單擊的中心div內容。更改列表中點擊div的內容?
我使用NG-CLICK和NG-REPEAT來獲取點擊並從JSON生成列表。
angular.module('duall')
.controller('documentationController', [
\t '$scope',
\t '$http', \t
\t function($scope, $http){
\t $scope.docs = [];
\t
\t $http.get('static/titles.json').success(function(doc){
\t \t $scope.docs = doc;
\t }).error(function(error){
\t \t console.log(error);
\t });
\t $scope.cliked = function(index){
\t \t $scope.item = $scope.docs[index]
\t };
}]);
<div ng-controller="documentationController">
<div class="row">
<div class="col s3" >
<div class="input-field col s12" >
<input id="search" type="search" ng-model="q" aria-label="filter docs"/>
<label for="search"><strong>Pesquise Algo! :)</strong></label>
<i class="material-icons prefix">search</i>
</div>
<ul class="animate-container">
<!-- <li ng-repeat="docs in docs | orderBy:'title' | filter:q as results "> -->
<li ng-repeat="docs in docs | filter:q as results ">
<i class="material-icons tiny">search</i>
<a ng-click="cliked($index)" href="">{{docs.title}}</a>
<div class="divider"></div>
<br>
</li>
<li ng-if="results.length === 0">
<strong>Nada encontrado :(</strong>
</li>
</ul>
</div> <!-- Fim col s3 -->
<div class="col s9">
<div class="container">
CONTENT CLICKED MUST BE HERE!
</div>
</div>
</div><!-- Fim col s9 -->
</div><!-- fim ROW -->
</div><!-- Fim Controller -->
偉大的!作品! – Andiie