You are mixing angular scope with dom manipulation. They are two different
things so not surprised you are having trouble. $scope values should point
to javascript literals, objects, arrays, but not to dom elements. You
can't call a jquery method without wrapping it first.... Try this:
$scope.modif = function (e) {
var temp =
angular.element(e.target.offsetParent.offsetParent.childNodes[3].childNodes[(this.$index+1)*2]);
temp.childNodes[11].html($compile('<button
ng-click="save($event)">Save</button>')($scope));};
On Sunday, March 9, 2014 9:48:20 AM UTC-6, François S wrote:
>
> I have un little problem with DOM manipulation.
>
> Here's my angular function:
>
> $scope.modif = function (e) {
> $scope.temp =
> e.target.offsetParent.offsetParent.childNodes[3].childNodes[(this.$index+1)*2];
> $scope.temp.childNodes[11].innerHTML = $compile('<button
> ng-click="save($event)">Save</button>')($scope);};
>
> but my button is rendered like that in the document:
>
> [[object HTMLButtonElement]
>
> I know that using innerHTML with Angular is wrong but when i'm using
> .html() i have this error:
>
> $scope.modif = function (e) {
> $scope.temp =
> e.target.offsetParent.offsetParent.childNodes[3].childNodes[(this.$index+1)*2];
> $scope.temp.childNodes[11].html($compile('<button
> ng-click="save($event)">Save</button>')($scope));};
>
> TypeError: undefined is not a function at h.$scope.modif
>
> Thanks,
>
> François
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.