-4

I have a dropdown list which is used for holding Email Templates . Now , I have categorized this into two types of Templates . One is 'User Generated Templates' and other 'System Generated Templates' .

I have the functionality to keep adding the Templates and they get populates into the Dropdown .

The important part here is to "Group" the Templates as 'Email' and 'System'. I have a condition that, Whenever "USER TEMPLATES" are added , they should be placed above the "system templates"

I need to do populate a Dropdown list such that it gets grouped according to the "User" and "System" templates with AngularJS . How do i do this ?

Seeking Help !

3
  • I'm sorry, but I can't see any question here. Please edit your post and write down what seems to be the problem. Commented Mar 17, 2015 at 15:52
  • @EelLee : I wish to populate dropdown such tht it gets grouped according to the types Commented Mar 17, 2015 at 15:54
  • Can you post any code? Commented Mar 17, 2015 at 16:04

1 Answer 1

0

Assuming the following structure for the templates :

$scope.templates = [{
    type: 'Email',
    name: 'Template u1'
}, {
    type: 'Email',
    name: 'Template u2'
}, {
    type: 'System',
    name: 'Template s1'
}, {
    type: 'Email',
    name: 'Template u3'
}, {
    type: 'System',
    name: 'Template s2'
}, {
    type: 'System',
    name: 'Template s3'
}];

If you want to group them by type in the dropdown you will declare your select element like that :

<select ng-model="template" ng-options="template.name group by template.type for template in templates">
    <option value=''>Select a template</option>
</select>

Refer to this fiddle

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for the answer . .. Need one more help .. I am using <input file >for file uploading multiple files . I need to make client side validations for accepting only "txt/pdf/doc" files without using any plugin/library .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.