首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ng-show未按预期工作

ng-show未按预期工作
EN

Stack Overflow用户
提问于 2015-05-25 19:45:18
回答 1查看 204关注 0票数 0

我尝试过的代码是:

html代码(updata.html)

代码语言:javascript
复制
<form role="form" ng-submit="submit()">
<input type="text" ng-model="query" >
      <div class="item item-input item-stacked-label item-divider">
      <li ng-repeat="name in names | filter:query" ng-show="(!name.selected&&query)">
      <button type="button" ng-click="name.selected=true; addname(name)">{{name.name}}</button>
    </li>

      </div>
      <li ng-repeat="name in names" ng-show="name.selected">{{name.name}}</li>
 <div class="padding">
      <button type="submit" class="button button-block button-positive">Submit</button>
    </div>
</form>

angular js代码

代码语言:javascript
复制
 angular.module('starter', ['ionic','ngCordova','ngRoute'])
.run(function($ionicPlatform) {
 $ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the   accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
  cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
  StatusBar.styleDefault();
}
});
})
.config(['$routeProvider',function($routeProvider) {
 $routeProvider.when(
 '/',{
  templateUrl: 'main.html',
  controller: 'datactr'
}
)
.when(
'/indata',{
  templateUrl:'updata.html',
  controller:'datactr'
})
.when(
'/outdata',{
  templateUrl:'outdata.html',
  controller:'datactr'
})
.otherwise({
redirectTo:'/'
})
}])
.controller('datactr',['$scope','$http',function($scope,$http) {
$scope.submit=function(){
          console.log("step1");

    $http({
      method:'POST',
      url:'http://awesomeg.2fh.co/updata.php',
      crossDomain : true,
      data:{
         'name':$scope.namefinal
          }
      }).success(function(data,status,header,config){
      console.log("step2");
      console.log(data);
      $scope.namefinal="";
      $scope.message="You have successfully updated the database";
    })
    $scope.names=[{'name' :'harry',
'selected':false},{'name' :'george',
'selected':false}];
$scope.namefinal=[];
$scope.addname=function(test){
$scope.namefinal.push(test.name);
}     
}])

这是我的离子code.Names的一部分,是一个对象数组,包含属性name和selected.so,当用户输入一个名称时,它会给你一个建议,suggesstions.when的selected属性被更改为true.What,然后会在底部看到一个选定对象名称的列表,但没有显示。

有人能帮上忙吗?

EN

回答 1

Stack Overflow用户

发布于 2015-05-25 19:48:30

我想是拼写错误。

代码语言:javascript
复制
<li ng-repeat="name in names | filter:query" ng-show="(!name.setected&&query)">

应该是ng-show="(!name.selected&&query)"

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30437624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档