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 8736031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:12:41+00:00 2026-06-13T10:12:41+00:00

I am fairly new to using AngularJS, and what I am trying to do

  • 0

I am fairly new to using AngularJS, and what I am trying to do is create a directive and call functions from the parent scope within it. I am able to accomplish this, but what I can’t seem to figure out is how to pass data from the isolate scope via an expression to the parent scope. The explanation of this in the Angular Developer guide is a little confusing.

The directive:

app.directive('myDir', function() {
    return {
        restrict: 'E',
        template: '<div ng-click="parentFunc(someValue)"><div>', 
        scope: {
           parentProp: '=property',
           parentFunc: '&func'
        },
        link: function(scope, element, attrs) {

        }
    }
});

The markup:

<my-dir prop="foo" func="bar(someValue)"></my-dir>

The controller:

app.controller('TstCtrl', function($scope) {
    $scope.foo = 'test';
    $scope.bar = function(value) {
       console.log(value);
    };
});

Thanks in advance for the help!

  • 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-13T10:12:43+00:00Added an answer on June 13, 2026 at 10:12 am

    There may be other ways to do this but see this fiddle where you would pass in an object to the function using the same parameter names passed into your func attribute.

        link: function(scope, element, attrs) {
            scope.parentFunc({someValue:'testing'});            
        }
    

    So in this case since you called bar(someValue) in your func attribute you would want to pass in an object with someValue in your link function. You’re calling parentFunc because that’s what &func is linked to in your isolate scope.

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

Sidebar

Related Questions

I'm fairly new to C# and trying to create a mp3-player. I'm using a
I am fairly new to using SSRS and I would like to create a
Fairly new to Objective C and trying to work within Storyboards given it's the
I am fairly new to Matlab and I am using GUIDE to create a
I am fairly new to Python and using Python 3.2. I am trying to
I'm fairly new to using Forms Authentication and am trying to wrap my head
I am fairly new to using P/Invoke. So I am able to use P/Invoke
I'm fairly new to using Python, and I'm trying to get a hit timer
I'm using a fairly new install of Visual C++ 2008 Express. I'm trying to
I'm fairly new to using MySQL and I'm trying to understand what the most

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.