停止ng-show向文本字符串添加空格

时间:2019-01-29 18:52:49

标签: html angularjs

我正在尝试从一组文本框输入中创建文件路径,然后显示该文件路径。但是我正在使用的ng-show方法是在字符串中添加空格。无论如何,有什么方法可以防止这种情况发生,或者有其他方法可以防止这种情况发生?

<!DOCTYPE html>
<html lang="en">
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
    </head>
    
    <body>
        <div ng-app="">
            <div>
                Client:
            </div>
            <div>
                <input type="text"
                       name="client"
                       ng-model="client">     
            </div>    
            <div>
                Brand:
            </div>
            <div>
                <input type="text"
                       name="brand"
                       ng-model="brand">                          
            </div>
            <strong>
                <label ng-bind="client"></label>
                <label ng-show="client.length">\</label>
                <label ng-bind="brand"></label>
                <label ng-show="brand.length">\</label>
            </strong>
        </div>                
    </body>
</html>

1 个答案:

答案 0 :(得分:3)

<!DOCTYPE html>
<html lang="en">
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
    </head>
    
    <body>
        <div ng-app="">
            <div>
                Client:
            </div>
            <div>
                <input type="text"
                       name="client"
                       ng-model="client">     
            </div>    
            <div>
                Brand:
            </div>
            <div>
                <input type="text"
                       name="brand"
                       ng-model="brand">                          
            </div>
            <p>
               <span ng-bind="client" style="display: inline-block;"></span><span ng-show="client.length" style="display: inline-block;">/</span><span ng-bind="brand" style="display: inline-block;"></span><span ng-show="brand.length" style="display: inline-block;">/</span>
            </p>
        </div>                
    </body>
</html>

取消绑定和ng-show具有相同的效果。这只是一个html / css问题。我相信这就是您要寻找的。

How do I remove the space between inline-block elements?