I encountered a problem and have set up a JSFiddle to showcase
var myApp = angular.module("myApp", []);
myApp.component("bar", {
transclude: true,
template: '<div ng-transclude></div>',
controller: function ($scope, $element, $attrs) {
$scope.msg = "Hello";
setTimeout(function(){
$scope.msg = "Goodbye";
alert($scope.msg);
}, 3000)
}
});
HTML:
<body ng-app="myApp">
<bar>
{{ $parent.msg }}
</bar>
</body>
It appears that there is only one-way binding in the HTML as the view does not display "Goodbye" when the scope variable 'msg' is updated.
Should I be using $parent
? Have I misunderstood how scopes work? Am I handling transclusion correctly?
Edit
To clarify, the setTimeout
function used here is just an example. In my actual scenario, I am trying to incorporate components for .
Instead of setTimeout
, I am actually attaching a 'complete' event listener to a PreLoadJS LoadQueue