根据下拉列表中的选择更改下拉列表名称

时间:2017-08-24 07:46:50

标签: html angularjs twitter-bootstrap-3

我想根据下拉菜单中的选项更改导航栏中的下拉列表名称。我发现html标签不支持ng-click。我已尝试过,但它没有用。帮我找到解决这个问题的方法。需要使用angularJs的解决方案,但最坏的情况是jQuery是可能的。

我的代码:

HTML

      <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
              <li><a href="#">Link</a></li>
              <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Current: {{currentApplication}}</a>
                  <ul class="dropdown-menu" ng-repeat="application in applications" ng-click="changeApplication(application.name)">
                      <li><a href="#">{{application.name}}</a></li>
                  </ul>
              </li>
          </ul>
      </div>

myApp.controller("navbarController", function ($scope, $http) {
  $scope.currentApplication = "default";

  var changeApplication = function(name) {
      $scope.currentApplication = name;
  };
  $http({
      method: 'GET',
      url: 'applications'
  }).then(function success(response) {
      $scope.applications = response.data,
  });
});

1 个答案:

答案 0 :(得分:0)

var context = new DbContext(); var type = Type.GetType($"XXX.XXXXXXX.XXXX.XXXXX.{exportItem.DataSourceView}, XXX.XXXXXXX.XXXX.XXXXX"); context.Set(type).Load(); var result = context.Set(type).AsQueryable().Cast<View_DataLoad>().ToList(); 什么也没做,因为你将函数定义为:

ng-click="changeApplication

绑定到var changeApplication = function(name) { $scope.currentApplication = name; }; as:

$scope