Hi,
maybe with list-item (no uppercase on item) it would be better ?
Le lundi 22 février 2016 19:18:26 UTC+1, Achach Ach a écrit :
>
> Hello,
>
>
> I want to display a list item from a "test.json" file.
>
>
> *File content* :[{"id":"1","name":"ABC"}, {"id":"2","name":"DEF"}]
>
>
> I added two alert () "SUCCESS A" and "SUCCESS B "
> it displays first "SUCCESS B" empty. and "SUCCESS A" with
> [{"id":"1","name":"ABC"},
> {"id":"2","name":"DEF"}]
>
>
> but my template "<list-Item></list-Item>" shows nothing !
>
>
> Can you help me ?
>
>
> Here is the code :
>
>
> *template* :
>
> <ion-view view-title="List test">
> <ion-content class="padding">
> <h3>List test</h3>
> <list-Item></list-Item>
> </ion-content>
> </ion-view>
>
>
> *Controller* :
>
> app.controller('List', function ($scope,itemProvider) {
> $scope.items = itemProvider.getItems();
> });
>
> *Service* :
> var items = [];
> app.service('itemProvider', function($ionicPlatform,$cordovaFile) {
> this.getItems = function () {
> $ionicPlatform.ready(function () {
> // READ
> $cordovaFile.readAsText(cordova.file.dataDirectory,
> "test.json")
> .then(function (success) {
> // success
> items = success;
> alert("SUCCESS A : " + items);
> }, function (error) {
> // error
> alert("ERROR:" + error);
> });
> });
> alert("SUCCESS B : " + items);
> return items;
> }
> })
>
>
>
> *directive* :
>
> app.directive('listItem', function() {
> return {
> templateUrl: 'views/directives/listItem.html',
> restrict : 'E',
> scope: true
> }
> })
>
>
> *Template directive* :
>
> <label class="item item-input item-stacked-label">
> <ion-list list-Item>
> <ion-radio ng-if="item.name" ng-repeat="item in items"
> ng-model="choice" ng-value="item.name"><b>{{item.name}} </b>- id:
> {{item.id}}</ion-radio>
> </ion-list>
> </label>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.