search

Home  >  Q&A  >  body text

angular.js - I want to use angular to simulate the select drop-down box effect, as shown below, but I don’t know how to achieve it?

When the user clicks on the p (A) of "Wuhan", a drop-down box p (B) will appear. The content in B is dynamically generated. Then click on any content in B, and then assign it to A. area, and then B is hidden.

高洛峰高洛峰2841 days ago533

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-05-15 17:02:11

    Look for open source reference
    https://github.com/angular-ui/ui-select

    reply
    0
  • ringa_lee

    ringa_lee2017-05-15 17:02:11

    controller:

    $scope.names = [{
        name: 'tom'
    },{
        name: 'jack'
    },{
        name: 'xiaoming'
    }];
    

    html

    <p>
        <select ng-options="names.name for names in names">
            <option value="">请选择</option>  <!-- 直接用模型值第一个会为空,所以这里填充第一个 -->
        </select>
    </p>

    reply
    0
  • Cancelreply