-
Notifications
You must be signed in to change notification settings - Fork 354
Initial version of the ui-input directive - RFC #191
Conversation
Nice one Pawel. Does it really need the InputHelper as a service rather than simply a local function? |
@petebacondarwin He's following an example I did in keypress so that I could reuse the same linking function in multiple directives. ATM I don't know a better way to do this
|
@petebacondarwin I would love to avoid declaring a service, but simply don't know how to do it.... We have discussed this with @ProLoser and couldn't find any better approach... But it would be great if we could avoid declaring those helper services.... @ProLoser still going over your comments but it is true that we could pull |
Another bullet
|
Since I will be needing this in the very near future, I'm working on my interpretation of an alternative structure: http://plnkr.co/edit/Ehnvjl Unfortunately, unlike @pkozlowski-opensource mine doesn't work at the moment lol. Major differences
Certain thoughts / ideas
|
For some reason $compile() is throwing an error Stubbed out uiForm dependency but need help creating the directive
If you guys could help me figure out why $compile() is throwing a completely cryptic error that would be awesome. |
|
||
//expose model to a field's template | ||
scope.$input = input; | ||
$compile(element.contents())(scope); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $compile errors because of the ng-transcludes. It doesn't know what to do. You'll have to manually transclude the elements with ng-transclude attribute, then remove them before $compiling.
OR alternatively, you could try putting in all the html during compile phase, and it might know how to use the transcludes. But you don't scope during compile phase, so that would hard to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Touché, I guess I just figured that ng-transclude was not actually a
directive but a subset.
On Oct 31, 2012 7:46 PM, "Andy Joslin" [email protected] wrote:
In modules/directives/input/input.js:
element.html(response);
var inputEl = element.find('[ng-transclude]');
angular.forEach(tAttrs, function (value, key) {
if (key.charAt(0) !== '$' && ['src','uiInput'].indexOf(key) === -1) {
inputEl.attr(snake_case(key, '-'), value);
}
});
//prepare validation messages
input.validation = angular.extend({}, uiConfig.input.validation, scope.$eval(tAttrs.validation));
//expose model to a field's template
scope.$input = input;
$compile(element.contents())(scope);
I think $compile errors because of the ng-transcludes. It doesn't know
what to do. You'll have to manually transclude the elements with
ng-transclude attribute, then remove it before $compiling.—
Reply to this email directly or view it on GitHubhttps://github.com//pull/191/files#r2001035.
So things I'm running into:
I added a template at the top of the file that I'm using for testing. |
Does someone have a working example of the current code?
because jQuery throws the error: "type property can't be changed" I would like to get the ui-input directives with different input types in the plunkers previously posted here by pkozlowski-opensource and ProLoser to work (they don't with the current code) A plunker showing the failure of the directive with type attribute is here: http://plnkr.co/edit/8jN2PA
Also, not understanding why the $parent scope is used in the ui-input directive ng-model attribute?
|
Here is an update on this: http://plnkr.co/edit/3zMsNnpNfOFwExSqLj2I?p=preview. |
I guess this one is no longer relevant... |
I'd still like to see this implemented eventually but yeah who's got the time. |
This is initial version of the code for the new ui-input family of directives (ui-input, ui-select, ui-textarea) as described in the issue #189.
You can see it in action in this plunk: http://embed.plnkr.co/TT1t1p
From the last discussion on the mailing list several things have changed:
There are still plenty of things that should be discussed done (no tests for the moment!) but I feel like this is a good starting point. I've started to use it a bit already and it is extremely powerful, it really makes it possible to write forms with the consistent look & fell - fast!
Let's discuss the concepts behind and the implementation itself!