0

i'm working on something pretty simple but there is this one thing I just can't get to work. Part of my application requires me to create href tags dynamically. But the part of the view that holds the navigation links always loads before i have a chance to inject the data into the scope.

 <a ng-href="#campus/{{$scope.currentCampusName}}/floor/{{$scope.currentFloor + 1}}">up</a>

that's the url i'm using and it always ends up like

 <baseurl>#/campus//floor/1

the strange part is that another block, which uses ng-repeat does wait for the controller to load it seems. So that loads correctly, but the link doesn't.

I've read about resolve but at this point i'm just confused... why does it work with ng-repeat but not in the ng-href ? Not to mention, what's the difference between using resolve and just calling the async service in your controller?

What am i missing?

killernerd
  • 377
  • 2
  • 6
  • 21

1 Answers1

2

You don't need $scope in interpolation mark {{}}

<a ng-href="#campus/{{currentCampusName}}/floor/{{currentFloor + 1}}">up</a>
hjl
  • 2,794
  • 3
  • 18
  • 26
  • really? REALLY? that was it? Tell me, what's the difference? the variable is inside the scope so why would using the full notation break it? Thanks though, that was indeed the issue... I feel stupid now. – killernerd Jan 11 '15 at 14:01
  • really...really...as everything in `{{}}` should be retrieved from scope, so that would be a redundant to add a prefix `$scope` that's the way angular design i think. – hjl Jan 11 '15 at 14:05
  • fair enough that it's redundant but to think that it breaks your application... Oh well, thanks for your help. Learned something new today. – killernerd Jan 11 '15 at 14:23