Updating to 0.10.7 - inputType?

170 views
Skip to first unread message

Robert B. Weeks

unread,
Mar 7, 2012, 4:50:04 PM3/7/12
to ang...@googlegroups.com
Hello -

In upgrading to 0.10.7 from 0.10.5 - one of the things I see missing in the latest builds is the ability to create an inputType - or just a different way that I can't seem to find to replace.

Whereas before we had something like:

angular.inputType('textAreaList', function(){
this.$parseModel = function(){
if (this.$modelValue) {
this.$viewValue = this.$modelValue.join('\n');
}
};
this.$parseView = function(){
this.$modelValue = this.$viewValue.split('\n');
};
});

are we supposed to define these as directives somehow now?

Thanks.

--
Robert B. Weeks


Peter Bacon Darwin

unread,
Mar 8, 2012, 8:42:37 AM3/8/12
to ang...@googlegroups.com

Robert B. Weeks

unread,
Mar 8, 2012, 9:34:09 AM3/8/12
to ang...@googlegroups.com
Hello -

Yes - I have looked at these in my local build docs - but that isn't really helping in re-creating the input type we created below so can use:

<input type="textAreaList" ..../>

Before you could define them - I assume it is a directive based now (like below) - but still having issues being able to make it behave/work like before. I just must be missing something. Brain going to much trying to re-do all of our 0.10.5 apps up to latest release has been a bit daunting to say the least. :)

Thanks for the response.


> Take a look at:
> http://ci.angularjs.org/job/angular.js-angular-master/232/artifact/build/pkg/0.10.7-64912069/docs-0.10.7-64912069/api/angular.module.ng.$compileProvider.directive.input
> and:
> http://ci.angularjs.org/job/angular.js-angular-master/232/artifact/build/pkg/0.10.7-64912069/docs-0.10.7-64912069/api/angular.module.ng.$compileProvider.directive
>
> On 7 March 2012 21:50, Robert B. Weeks <vai...@mac.com> wrote:
> Hello -
>
> In upgrading to 0.10.7 from 0.10.5 - one of the things I see missing in the latest builds is the ability to create an inputType - or just a different way that I can't seem to find to replace.
>
> Whereas before we had something like:
>
> angular.inputType('textAreaList', function(){
> this.$parseModel = function(){
> if (this.$modelValue) {
> this.$viewValue = this.$modelValue.join('\n');
> }
> };
> this.$parseView = function(){
> this.$modelValue = this.$viewValue.split('\n');
> };
> });
>
> are we supposed to define these as directives somehow now?
>
> Thanks.
>
> --
> Robert B. Weeks
>


--
Robert B. Weeks


Vojta Jína

unread,
Mar 10, 2012, 8:56:37 PM3/10/12
to ang...@googlegroups.com
Hey Robert, sorry for confusion, we removed custom inputTypes as it turned out to not be a good solution.
Now, any directive have access to validation through NgModelController.

V.

Robert B. Weeks

unread,
Mar 11, 2012, 8:34:59 AM3/11/12
to ang...@googlegroups.com

Hey -

Oh no - forms are changing a lot again? As big of a change as the 0.10.x form change? Ugh - we might be stuck keeping 0.10.5 if so (well with this and the compiler question I have in here as well). :|


But as for input types not being a good solution - we use them and they actually did what we needed - so there are no way to mimic this? Validation had nothing to do with why we created them - but for example - the one described in my mail enabled us to create dynamic JSON arrays out of textarea inputs - how would you suggest we accomplish this in the new way?


--
Robert B. Weeks


Peter Bacon Darwin

unread,
Mar 11, 2012, 11:30:25 AM3/11/12
to ang...@googlegroups.com
Hi Robert,
Take a look at the ng:list directive:  https://github.com/angular/angular.js/blob/master/src/directive/input.js#L1142 
This appears to modify the default behaviour of an the input element so that the connected model that is updated with a list of comma separated items from the element's value.  This particular directive splits the string from the input element at commas but I imagine you could either create your own one which split at carriage returns or one could get the nice people at AngularJS to change this directive to accept an attribute which specified the string on which to split/join.
Pete 

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.

Peter Bacon Darwin

unread,
Mar 11, 2012, 3:43:25 PM3/11/12
to ang...@googlegroups.com
Hi Vojta,
In the dev_guide.forms page below there is a fiddle for a Simple Form.  Here it is:  http://jsfiddle.net/petebd/yW6F7/.
I noticed that if you enter an invalid email address the widget correctly displays with a red border and doesn't copy to the user.email model.
But if you then hit the reset button, the email address is not cleared, since the user.email model value has not changed.  Is this a bug in the widget or in the form reset code, or is it expected?
Cheers,
Pete

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.

Vojta Jína

unread,
Mar 13, 2012, 2:05:05 AM3/13/12
to ang...@googlegroups.com
I think allowing ng-list to specify a separator is a valid feature, here is a pull request:

V.

Vojta Jína

unread,
Mar 13, 2012, 2:09:11 AM3/13/12
to ang...@googlegroups.com
Hey Pete,

good catch. I know about it. I was kinda hoping, that no one will notice that :-D, but yep it sucks, it's not correct behavior.
Unfortunately, not sure how to solve it now... We will probably need som explicit method for just cleaning the invalid view or something... Need to thing about it.

V.

Robert B. Weeks

unread,
Mar 13, 2012, 8:57:00 AM3/13/12
to ang...@googlegroups.com
Hey Vojta -

> I think allowing ng-list to specify a separator is a valid feature, here is a pull request:
> https://github.com/angular/angular.js/pull/786
>
> V.

I think this would be a great addition. Would allow like we are using it for - a textarea that will take each line (\n) and append an array/list.

Thanks!

--
Robert B. Weeks


Vojta Jína

unread,
Mar 15, 2012, 2:43:31 AM3/15/12
to ang...@googlegroups.com
Yep, it's already in master and released.
Actually, we added support for regexps as well, so you can do:
<textarea ng-model="some" ng-list="/,|:/">

V.

dua khaliq

unread,
Jun 12, 2014, 12:04:31 AM6/12/14
to ang...@googlegroups.com
hi, i am new to Angularjs. i need to know about splitting a string. The scenario is that i have the back end data in json-LD form. One of the value that i want to bind with the input is stored as **"href": "/articles/1328196047309"**. Now what i want is to show just the part after ":" (colon). how can i do it in the view?

if i need to make a filter how would that work?

Eric Eslinger

unread,
Jun 12, 2014, 12:42:10 AM6/12/14
to ang...@googlegroups.com
if the string is in JSON from, you can use obj = JSON.parse(string) and then just have at obj as you would an object.

e

Dua Khaliq

unread,
Jun 12, 2014, 12:59:34 AM6/12/14
to ang...@googlegroups.com
json is easy, but dealing with jsonLD this time so its difficult. 
can i use some custom filters?


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/3FTJTp-brmA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.



--
Regards
 ~Tehreem  Khaliq 
Reply all
Reply to author
Forward
0 new messages