Is there a way to do the same with ng-view
I can't think of a way to do this without editing the Angular source or something else. replaceDesigned for custom directives, not (required) inline ones.
or, as a rule, any Angular directive? Thanks for the help!
. - , , . , template'd ( , ), , , , .
, , Angular , " " , , , .
ngInclude/ngView -esque, .
, , (, , ) :
app.directive('myRender', function ($compile, $http) {
return {
restrict: 'E',
link: function (scope, element, attrs) {
var newScope;
var newElement;
attrs.$observe('url', function (value) {
if (value) {
$http.get(value).then(function (result) {
if (newElement !== undefined) {
newElement.remove();
}
newElement = angular.element(result.data);
if (newScope !== undefined) {
newScope.$destroy();
}
newScope = scope.$new();
$compile(newElement)(newScope);
element.parent().append(newElement);
});
}
})
}
}
});
http://plnkr.co/edit/Vm96f2rQsT2PX1C3rgK8?p=preview
- css Angular, angular.
angular, .