按钮单击时重新初始化指令

时间:2015-03-07 14:31:35

标签: angularjs angularjs-directive angularjs-scope

我正在使用multi select directive角度。从按钮中选择了一些值后,按钮标签会更新以反映更改。我想在按钮点击时刷新/重新初始化指令而不刷新页面,以便按钮返回到原始状态。请在下面找到plunker的链接。

Punker:http://plnkr.co/edit/52kgSkn0V3qwH4NkAAad?p=preview

<html>
  <head>
    <script data-require="angular.js@1.3.14" data-semver="1.3.14" src="https://code.angularjs.org/1.3.14/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <link rel="stylesheet" href="isteven-multi-select.css" />
    <script src="isteven-multi-select.js"></script>
    <script src="script.js"></script>
  </head>

  <body ng-app="myApp" ng-controller="main" >
    <div>
      <div isteven-multi-select
        max-labels="2" 
        input-model="plugins" 
        output-model="chosenPlugins" 
        button-label="name" 
        item-label="name" 
        tick-property="selected">
      </div>
      <div>
        Plugins: {{ chosenPlugins }}
      </div>
      <div>
        <button ng-click="resetDirective()">Reset</button>
      </div>
    </div>
  </body>
</html>

0 个答案:

没有答案