简体   繁体   English

ng-model无法在ui-bootstrap角星级中使用

[英]ng-model not working in angular ui-bootstrap star rating

I am trying to create a simple star rating input via angular ui-bootstrap. 我试图通过角度ui-bootstrap创建一个简单的星级输入。 The code works fine except that the ng-model is not grabbing the value from the model. 该代码工作正常,除了ng-model不会从模型中获取值。

Here is the markup: 这是标记:

<div ng-controller="shopperFeedbackController">
        <div class="row feedback-rating-row" >
            <div class="col-sm-16">
                <div class="feedback-label">
                    Rating:
                </div>

                <div class="feedback-rating-star-input">
                    <rating ng-model="rate" <--- Not working
                            max="max_rating" 
                            on-hover="hovering_over(value)" 
                            on-leave="overStar = null" 
                            titles="['one','two','three']" >
                    </rating>
                </div>
            </div>
        </div>
   </div> 

And the code: 和代码:

snbApp.controller('shopperFeedbackController', function ($scope) {
  $scope.max_rating = 5;
  $scope.rate = 3;
});

I have reproduced your code in a plunker. 我已将您的代码复制到一个插件中。

The rating code is working, but you have a problem with the CSS row class, in the following line: 评级代码有效,但是您在以下行中遇到了CSS row类的问题:

<div class="row feedback-rating-row">

See plunker 朋克

The row is adding a margin-left: -15px; row margin-left: -15px;添加了一个margin-left: -15px; and the first star goes out of the viewport. 并且第一颗星星从视口中消失。

The ui-bootstrap version I was using was 0.13.3. 我使用的ui-bootstrap版本是0.13.3。 I changed it to the latest (0.13.4) and it worked. 我将其更改为最新版本(0.13.4),并且可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM