Insert a small form into a dropDown directive

2019-09-18 15:30发布

问题:

I need help with this plunker

On my job i need open a small dropdown, that will contain a small form. It must be a directive.

1- My directive will receive a model (something that i don't know why, it doent's show)

2- the model must be printed on the input

3- with the save button the new paremeter writen must pass by a callback to the paren

  1. if i click out the dropdown or if i click cancel button, the dropdown must close.

can any body help me with this job?

Really thanks

<body class="container" ng-controller="mainCtrl" dropdown-listener>

  <h1>option DropDown</h1>

  original data: <h4>{{profile.city}},{{profile.province}},{{profile.country}}</h4>

  <dropdown-multiselect user-profile="profile"></dropdown-multiselect>

</body>

回答1:

I think I have something that is close to what you are looking for.

The first thing you need is the auto-close set to disabled on your dropdown so it doesn't close as soon as you click on it.

<div class="btn-group" dropdown auto-close="disabled" is-open="isopen">

You also had a problem where you were trying to directly link the form inputs to the outer variables. I presume you only want to set those when "submit" is pressed?

Anyways... have a look at this plunker and see if it's closer to what you're looking for.

http://plnkr.co/edit/rK3gmN9rHksZrGuEM6r6?p=preview

Edited the plunker to now have initial values using ng-init.

<input type="text" id="ciudad" ng-init="profile.country=initProfile.country" ng-model="profile.country"></input>