-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Form $dirty and $valid broken with fields inside tabs #574
Comments
OK, let's close this as a duplicate of #524 then |
Thanks for pointing me in that direction, wouldn't have found that otherwise - appreciated. |
This isn't fixed as I originally thought... Compiling the From what I can tell, fields that are nested inside a tab, and then an ng-repeat seem to retain their bindings. Those that are placed in the tab content area but NOT inside an ng-repeat don't display the values of their models. |
@pkozlowski-opensource, @ajoslin Here's a plunker demonstrating the above issue: http://plunker.co/edit/D6URYjfBQgtQ37nXQS1k?p=preview Line 2434 of bootstrap.js in that plunker has the fix suggested in #524. As you can see, on-load the initial value is bound in the "Form details" section, but the input itself doesn't get the value initially. If you remove the line |
I updated my plunkr with the latest tabs.js from be7ecff http://plunker.co/edit/aEKvVwzHtcokTsYMMc2f?p=preview In your test, I noticed that the In my plunkr, $scope.client is defined in the parent controller, and then both inputs are set to have If I set the inner inputs |
ng-options are duplicated inside tab!! |
The problem is the content elements are getting 'double-compiled'. Fixed that, working on a couple more fixes. Will commit soon :-) |
very nice..:-) |
* Before, tab content was being transcluded before the tab content area was ready. This forced us to disconnect the tab contents from the DOM temporarily, then reocnnect them later. This caused a lot of problems. * Now, neither the tab content or header are transcluded until both the heading and content areas are loaded. This is simpler and fixes many weird compilation bugs.
Thank you Andy. You saved my day:-) |
Thanks a lot @ajoslin . Working great now! |
It seems the issue has appeared back. I am having problems checking if the form located inside a tab is valid. See the plunker: http://plnkr.co/edit/aMOayrmbPPqDlTtUyuks?p=preview |
@nrdcp Tabs creates a new isolated scope and you're creating your form there. Setting something in a inner scope doesn't set it on the parent. TL;DR; The controller's scope is not aware of any form at all. |
Any luck with this bug? I have the same problem with 0.9 bootstrap ui |
@SaulBurgos As a workaround I ended up using the "tabset" directive and its templates from ui-bootstrap-tpls-0.6.0 |
Excuse me, what bug are we talking about? (@SaulBurgos, @nrdcp) If it is the message from @nrdcp 3 weeks ago. No, that is not a bug. |
Hi @Foxandxss "Tabs creates a new isolated scope and you're creating your form there. Setting something in a inner scope doesn't set it on the parent. TL;DR; The controller's scope is not aware of any form at all." But you did not say how to resolve this with a form inside a tabset. Ex: I want to access to my ngFormController of my scope to check the $valid and $dirty property of that form but the problem is how you said: tab create new isolated scope. So my question for you would be : How can I access to my ngFormController inside a tabset ? you can see the example here : http://plnkr.co/edit/HKyh1BJYL12knGMfkRq0?p=preview |
The problem is Javascript inheritance. If I have an $scope.foo = "Hello"; And then I create a new scope that is child of that one and I do: $scope.foo = "Bye";
$scope.meh = "Hi hi"; What would happen if I print Ok, what happen if parent does a Having that knowledge. Your controller has a What is happening in your plunker? In your first example you're creating a form in the child scope (like In the second example, you're printing it from the child scope, so there of course you see it. To make it work, is what we call the If you something like this in the parent: $scope.foo = {
bar: ''
} And then this in the child: $scope.foo.bar = "Hello"; You're NOT shadowing the parent in this case, it will get the parent's That is what you need to do here. Create a form using the Check here: http://plnkr.co/edit/R6v7EwQnQiDzK9HURqjL?p=preview Read that, is much much explanation that I could give you here. |
Thanks you for you explanation only for the record I made this example of how should work for everybody in the future: http://plnkr.co/edit/HKyh1BJYL12knGMfkRq0?p=preview some consideration that I think important :
Well if I wrong please correct me, I am not a expert on angular :). thanks @Foxandxss for your answer |
I like it. |
Is this fixed with angular 2 because I face this problem. |
I'm not sure if this is an implementation issue on my end, or a bug with the tabs directive, but I've asked around and most responses I've gotten seem to indicate it might be the latter.
When form fields are inside tabs, and that tabset is nested inside a
<form>
, the form's $dirty and $valid properties are not affected by the field(s) inside the tabset.Plunkr here: http://plunker.co/edit/dCSE1jyLYIWY342mQfAl?p=preview
The text was updated successfully, but these errors were encountered: