I am currently implementing Google's embedded maps into a project and created and angular directive for it.
I want to be able to update the url being used with values being passed in through attributes for the directive, however after changing the selected item, the value being displayed is always one behind the currently selected value.
Here is my link function:
function link (scope, element) {
makeIFrame(scope, element);
scope.$on('place-change', function () {
makeIFrame(scope, element);
});
}
And my makeIFrame function:
function makeIFrame(scope, element) {
element[0].innerHTML = baseURL+scope.name +' '+ scope.zip;
}
Here is a jsfiddle of the problem, I am just displaying an example of the url I would use: http://jsfiddle.net/t2GAS/60/
I am also wondering is there a better practice for performing tasks like this in a directive.
I tried using the template function but it did not access the values of the variables being passed and would try to parse the name of the variable instead.
EDIT:
Updated jsfiddle with Phil's answer: http://jsfiddle.net/t2GAS/64/
<iframe ng-src="{{theVariable}}"></iframe>