Note that there are some explanatory texts on larger screens.

plurals
  1. POadding more than one sources of data to angular
    primarykey
    data
    text
    <p>this is what I have in my model</p> <pre><code>// The contents of individual model .js files will be concatenated into dist/models.js (function() { // Protects views where angular is not loaded from errors if ( typeof angular == 'undefined' ) { return; }; var module = angular.module('myModel', ['restangular']); module.factory('myRestangular', function(Restangular) { return Restangular.withConfig(function(RestangularConfigurer) { RestangularConfigurer.setBaseUrl('http://localhost/data'); RestangularConfigurer.setRequestSuffix('.json'); RestangularConfigurer.setRestangularFields({ id: "my_id" }); }); }); })(); </code></pre> <p>this is fine. but now I have another json that I need to grab data from. How could I change this model to look for that other json as well. I am very very new to angular and still learning how model data binding works!</p> <p>*<em>This is what I have tired *</em></p> <p>my model</p> <pre><code>var module = angular.module('FloorModel', ['restangular']); module.factory('FloorRestangular', function(Restangular) { return Restangular.withConfig(function(RestangularConfigurer) { RestangularConfigurer.setBaseUrl('http://localhost/data/floor'); RestangularConfigurer.setRequestSuffix('.json'); RestangularConfigurer.setRestangularFields({ id: "floor_id" }); }); }); **my controller** myApp.controller('FloorCtrl', function ($scope, $filter, FloorRestangular) { // Fetch all objects from the local JSON (see app/models/mdpocket.js) FloorRestangular.all('floor').getList().then( function(floors) { // Then select the one based on the view's id query parameter $scope.floor = $filter('filter')(floors, {floor_id: steroids.view.params['id']})[0]; }); // -- Native navigation steroids.view.navigationBar.show("Floor: " + steroids.view.params.id ); }); </code></pre> <p>*<em>my view *</em></p> <pre><code>&lt;div ng-app="myApp"&gt; &lt;div ng-controller="FloorCtrl"&gt; &lt;div class="topcoat-list__container"&gt; &lt;ul class="topcoat-list"&gt; &lt;li class="topcoat-list__item" hm-tap="open(floor.floor_id)" ng-repeat="floor in floors"&gt; Floor Name: {{ floor.name }} &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload