Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:11:52+00:00 2026-06-14T23:11:52+00:00

(sorry for my english :) I’m using Select2 in my forms with AngularUI ui-select2

  • 0

(sorry for my english 🙂

I’m using Select2 in my forms with AngularUI ui-select2 directive like this:

<input ng-model="city" type="text" ui-select2="setupCitySelect" />

where setupCitySelect – object with select2 options. I’m setting him up in appropriate scope

$scope.setupCitySelect = {
    allowClear: true,
    minimumInputLength: 2

    ...etc, about 50 SLOC
}

All works fine. But when we have, let say, five select2 elements on page (or part of page) – CitySelect, UserSelect, ConditionSelect etc. we get a tons of code, most of them is the same. AngularUI provides “Global Defaults”. So we can move repeating code (in directives):

var dirs = angular.module('vipc.directives', ['ui']);

// defaults setting for UI
dirs.value('ui.config', {
    select2: {
        allowClear: true,
        minimumInputLength: 2,
        formatInputTooShort: function(term, minLenght) {
            var rest = minLenght - term.length;
            return "minimum: "+rest;
        },
...etc.

But we still need some work in controllers: to set unique properties, such as ajax-url…
And it’s come on several pages, several controller. Ough…
Yes, I can put this into one file, say common.js. But I think – it’s not best way. Angulas say: “use directive, Luke!”. But how? Too complicated docs. I read docs. Three times.
Without success. I wrote some simple dirs, but this…
It should had ‘isolated’ scope – can be 2 CitySelect on page – in search form and modal form above. compile function? link function?

All i need is just

<myapp-city-select id="city"></myapp-city-select>
<myapp-user-select></myapp-city-select>
...later, same html file
<myapp-city-select id="city2"></myapp-city-select>

Somebody can help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:11:53+00:00Added an answer on June 14, 2026 at 11:11 pm

    It should be in the controller. Here is the plunker. showing you that all directives share the same data.

    So you can have a directive with common options in the controller and pass specific options into it.

    Another option is have a service that defines common options and inject the service into wherever you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At first sorry my bad English. I want define routing for this url: For
at first sorry my bad English I want load model in my plugin controller
Sorry my lousy english, I'm sleepy and struggling with this about 3 days ago.
(sorry for my english), now it's my first time using WCF, so my question
Sorry for english First this is the main screen on my application: ok, so
Sorry for english this might be very basic Question, I have an Application where
Sorry ,my English is poor, I have never speak English after I leave the
sorry for my English. I write bash-file, that uses variable: shared_var=/system/xbin My script-file: exec=./adb
Sorry for my English. How I can add comment to Jpeg file to COM-marker
Sorry for bad English :( Suppose i can preliminary organize recipes and ingredients data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.