简体   繁体   English

Angular JS错误状态未显示

[英]Angular JS error states not showing

I have a Bootstrap 3 page with 3 panels and a numeric stepper to control the height of the panels. 我有一个包含3个面板的Bootstrap 3页面和一个数字步进器来控制面板的高度。 This part works fine, but I also am trying to add and error state message if the stepper goes to the minimum or over a value. 这部分工作正常,但如果步进器达到最小值或超过某个值,我也会尝试添加错误状态消息。 The stepper value is bound to the panels' height and works as expected. 步进器值绑定到面板的高度,并按预期工作。 The error does not display, though. 该错误不会显示,但是。

The basic angular part of the code is here: 代码的基本角度部分在这里:

<form class="form-inline" name="panel" no-validate>
        <div class="form-group" ng-class="{'has-error': panel.height.$error.min || panel.height.$error.max}" >
            <span>Change height:&nbsp;</span>
            <input class="form-control" name="height" style="display: inline-block; width: 70px;" type="number" min="150" max="400" step="25" ng-model="panelHeight" ng-init="panelHeight=200"  />
            <span ng-show="panel.height.$error.min">&nbsp;Height must be a minimum of 150.</span>
            <span ng-show="panel.height.$error.max">&nbsp;Height must be a maximum of 400.</span>
        </div>
    </form>

And a fiddle with the whole working code is here: http://jsfiddle.net/yLUaA/ 有关整个工作代码的小提琴在这里: http : //jsfiddle.net/yLUaA/

NOTE Apparently I am having issues removing just the right amount of code to make the fiddle work; 注意显然我在删除适当数量的代码以使小提琴无法正常工作时遇到了问题。 rest assured the panel sizing is working locally. 请放心,面板尺寸在本地有效。 Just not the error. 只是没有错误。

You're missing ng-app from the fiddle so that's most likely the cause in your local project. 您从小提琴中缺少ng-app ,所以这很可能是您本地项目中的原因。 ng-app should be assigned to the root element of your page, see ng-app documentation . ng-app应该分配给页面的根元素,请参阅ng-app文档

Working demo here: http://jsfiddle.net/yLUaA/3/ 此处的演示工作: http : //jsfiddle.net/yLUaA/3/

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

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