小编jay*_*flo的帖子

Angular JS可调整大小的div指令

我的网站将有多个部分,每个部分我打算可以调整大小.为了实现这一点,我制定了一个"可调整大小"的指令,例如:

<div class="workspace" resize="full" ng-style="resizeStyle()">
<div class="leftcol" resize="left" ng-style="resizeStyle()">
Run Code Online (Sandbox Code Playgroud)

使用类似于以下内容的指令:

lwpApp.directive('resize', function ($window) {
    return {
        scope: {},

        link: function (scope, element, attrs) {
            scope.getWinDim = function () {
                return {
                    'height': window.height(),
                    'width': window.width()
                };
            };

            // Get window dimensions when they change and return new element dimensions
            // based on attribute
            scope.$watch(scope.getWinDim, function (newValue, oldValue) {
                scope.resizeStyle = function () {
                    switch (attrs.resize) {
                    case 'full':
                        return {
                            'height': newValue.height,
                            'width': (newValue.width - dashboardwidth)
                        };

                    case 'left':
                        return …
Run Code Online (Sandbox Code Playgroud)

scope resize controller directive angularjs

45
推荐指数
2
解决办法
7万
查看次数

sed追加从stdout获得的文本

我知道sed可以通过几种不同的方式附加文本:

  1. 附加字符串NEW_TEXT:

    sed -i '/PATTERN/ a NEW_TEXT' file
    
    Run Code Online (Sandbox Code Playgroud)
  2. 附加文件内容file_with_new_text:

    sed -i '/PATTERN/ r file_with_new_text' file
    
    Run Code Online (Sandbox Code Playgroud)

但是,无论如何要sed通过stdout 追加文本管道吗?我希望得到相当于:

# XXX,YYY,ZZZ are line numbers
# The following appends lines XXX-YYY in file1
# after line ZZZ in file2.

sed 'XXX,YYY p' file1 > /tmp/file
sed -i 'ZZZ r /tmp/file' file2
Run Code Online (Sandbox Code Playgroud)

无需使用临时文件.这可能吗?

bash sed

4
推荐指数
1
解决办法
1992
查看次数

标签 统计

angularjs ×1

bash ×1

controller ×1

directive ×1

resize ×1

scope ×1

sed ×1