Hi!
Sorry if my question is trivial or so, just started with AngularJS a few
days ago...
I am trying to make a small form direcitve. Used like this:
%myform(data-ng-controller='AuthController')
... divs, input elements, ...
The myform should only extend the form element with some defaults and has
no own logic. Problem: AngularJS completely ignores the ng-controller, no
matter what I do with the directive scope.
angular.module('Sential5').directive 'myform', ->
restrict: 'E'
template: '<form autocomplete="off" novalidate=true
data-ng-transclude=true class="transclude"></form>'
replace: true
transclude: true
scope:true
link: ($scope, $element, $attr, $controller, $linker) ->
# Solution 1b:
$linker $scope, (clone) ->
console.log "append to...", $element.find('.transclude')
console.log "clone...", clone
$element.find('.transclude').append(clone)
There are 2 solutions here
<http://stackoverflow.com/questions/22575424/angularjs-ng-controller-on-directive-does-not-work-on-transcluded-elements-withi>
.
Solution 1a is deprecated.
Solution 1b is not working (because the element.find is always empty)
Solution 2 clones the whole form and it is displayed twice.
So what is the correct way to do that? Or is 1b working and I am too blind
to see my mistake?
Thank you very much in advance!
Kind regards,
Anton
--
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.