Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8369097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:33:37+00:00 2026-06-09T13:33:37+00:00

In my highest level scope, I fetch some data from the server for use

  • 0

In my highest level scope, I fetch some data from the server for use throughout the page like this: $scope.lotsOfData = $http.get("lotsOfData");. So now my scope holds a promise object for lotsOfData. Then, in my HTML, I have directives that are only concerned with a small set of the lotsOfData object. One such directive could look something like this:

<div>
    {{lotsOfData.foo.blah[source].bar[id].someData}}<br>
    {{lotsOfData.foo.blah[source].bar[id].otherData}}<br>
    {{lotsOfData.foo.blah[source].bar[id].differentData}}
</div>

where source and id are being set through attributes on the directive. My HTML page then looks something like this:

<data-subset source="1" id="1" />
<data-subset source="1" id="2" />
<data-subset source="2" id="1" />
<data-subset source="3" id="1" />

I hate having to repeat lotsOfData.foo.blah[source].bar[id] throughout the directive. Is there any way to set in the scope so my directive could look more like this?

<div>
    {{currObj.someData}}<br>
    {{currObj.otherData}}<br>
    {{currObj.differentData}}
</div>

Not only does this clean up the HTML, but if we ever restructure that lotsOfData object, there’s be only one place to change how it’s getting the currObj object. In the link function for my directive I tried this:

link: function(scope, element, attrs) {
    scope.currObj = scope.lotsOfData.foo.blah[attrs.source].bar[attrs.id];
}

However, since lotsOfData is a promise object, it doesn’t have a property called foo. I don’t know a whole lot about how the promise object works, so maybe I just need to know how I can get to the properties I need.

I hope what I’m trying to accomplish here makes sense and someone could point me in the right direction as to how to make this work. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:33:39+00:00Added an answer on June 9, 2026 at 1:33 pm

    This is how I accomplished what I wanted to. I created an outer directive to the one mentioned above and then created an isolated scope for the inner directive that bound to the data I wanted.

    So my outer directive HTML looks like this:

    <div>
        <data-subset curr-obj="lotsOfData.foo.blah[source].bar[id]"></data-subset>
    </div>
    

    And the javascript looks like this:

    myModule.directive('outer-data', function() {
            return {
                restrict: 'E',
                replace: true,
                templateUrl: 'outerData.html',
                link: function(scope, element, attrs) {
                    scope.id = attrs.id;
                    scope.source = attrs.source;
                },
                scope: true
            }
        });
    

    Then the javscript for my dataSubset looks like this:

    myModule.directive('dataSubset', function() {
            return {
                restrict: 'E',
                replace: true,
                templateUrl: 'dataSubset.htm',
                scope: {
                    currObj: '='
                }
            }
        });
    

    So then in my top-level HTML file I have something like this:

    <outer-data source="1" id="1" />
    <outer-data source="1" id="2" />
    <outer-data source="2" id="1" />
    <outer-data source="3" id="1" />
    

    And I can just reference currObj on my dataSubset like I wanted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want global variables that with highest level in this app so that it
I come from low level languages - C++ is the highest level I program
I would like to have my warnings set to the highest level using Microsoft
I want the Java compiler to give me the highest level of warnings possible.
So I have an iPhone application running that is controlled at the highest level
What is the highest class in the hierarchy I can use to pass HttpSessionState
I need to find the highest number from 3 different numbers. The only thing
How does this code work to Find the next highest power of 2 for
I have a table that looks something like this: CREATE TABLE student_results(id integer, name
What are the highest level languages that can be compiled to executables? When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.