directive isolated scope not available without templateUrl

54 views
Skip to first unread message

Derek Lin

unread,
Apr 24, 2015, 4:51:16 PM4/24/15
to ang...@googlegroups.com
I am using 1.4.  When writing a directive, if I don't use templateUrl, I am not able to pass variables into the isolated scope.  Is this a new feature or has it always been like this?

Sander Elias

unread,
Apr 25, 2015, 1:00:17 AM4/25/15
to ang...@googlegroups.com
Hi Derek,

Can you provide a plunk showing this issue? I can not confirm your findings.

Regards
Sander

Derek Lin

unread,
Apr 25, 2015, 1:27:52 AM4/25/15
to ang...@googlegroups.com
Hum... It's actually working here:

There are two things I am not sure of (I can only check Monday)

1. I maybe using 1.4-rc0 instead of 1.4-rc1.

2. I am using the new angular router

Will it be difficult for you to set up these two things in your plnkr base?  Btw, your plnkr base is really cool, a real time saver!

Thanks,

Derek

Sander Elias

unread,
Apr 25, 2015, 3:59:45 AM4/25/15
to ang...@googlegroups.com

Hi Derek,

No it’s not hard to set those 2 things up in my plunk.
For 1 just amend the number in <script src="https://code.angularjs.org/1.4.0-rc.1/angular.js"></script>
For 2, append this <script src='https://rawgit.com/angular/router/master/dist/router.es5.js'></script> just below the above line.

Your issue has to do with timing
http://plnkr.co/edit/7NdDAr8UhADNL3TCfExE?p=preview

does that help you enough?
Regards
Sander

Derek Lin

unread,
Apr 25, 2015, 1:34:46 PM4/25/15
to ang...@googlegroups.com
Hi Sander,

Thanks for the tips.  I was actually not able to reproduce the problem -- scope.info is always defined, in the direct mode.

What I have experienced is that, when I took out templateUrl, scope.info was undefined; and as soon as I put in templateUrl, scope.info was there.  How does templateUrl relate to the angular life cycle?

And I thought the link function, defaulting to post link function, is the last thing that the directive runs.  Did you suggest that sometimes the isolated scope will be hooked up, and other times won't?

Derek Lin

unread,
Apr 25, 2015, 2:06:23 PM4/25/15
to ang...@googlegroups.com
I have re-created the problem in the attached very simple app.  You can run it with http-server, like http-server -p 5000


It fails without the templateUrl.
isolated-scope-not-working-without-templateurl.zip

Sander Elias

unread,
Apr 26, 2015, 12:10:59 AM4/26/15
to ang...@googlegroups.com
Hi Derek,

Ok, now I can see your issue indeed. I'm digging in a bit now.

Regards
Sander

Sander Elias

unread,
Apr 26, 2015, 8:28:08 AM4/26/15
to ang...@googlegroups.com
Hi Derek,

I did build a plunk out of your sample, and created an github issue. 

Regards
Sander

Derek Lin

unread,
Apr 26, 2015, 12:17:33 PM4/26/15
to ang...@googlegroups.com
Sander,

Thank you!!
Reply all
Reply to author
Forward
0 new messages