Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs angular js双向绑定contenteditable via scope属性_Angularjs_Angularjs Directive_Contenteditable - Fatal编程技术网

Angularjs angular js双向绑定contenteditable via scope属性

Angularjs angular js双向绑定contenteditable via scope属性,angularjs,angularjs-directive,contenteditable,Angularjs,Angularjs Directive,Contenteditable,是否无法通过使用双向绑定的隔离作用域将值从父作用域设置为contentEditable指令 代码如下: HTML: 我有一个ng模型,设置为“你好!”在控制器中,是两个绑定到内容可编辑div的 contentEditable div不应该显示Hello 注意:可以像下面那样通过插值进行设置,但我想知道是否无法通过范围中的两个绑定进行设置 {{foo}}在尝试了一些选项之后,设置$watchs似乎是可能的。更新链接 <input ng-model="foo" /> &l

是否无法通过使用双向绑定的隔离作用域将值从父作用域设置为contentEditable指令

代码如下:

HTML:

我有一个ng模型,设置为“你好!”在控制器中,是两个绑定到内容可编辑div的

contentEditable div不应该显示Hello

注意:可以像下面那样通过插值进行设置,但我想知道是否无法通过范围中的两个绑定进行设置


{{foo}}在尝试了一些选项之后,设置$watchs似乎是可能的。更新链接
    <input ng-model="foo" />
    <div contentEditable="true" binding-foo="foo" ng-model="input.name" title="Click to     edit"></div> 
    <pre>model = {{input.name}}</pre>
    angular.module('form-example2', []).directive('contenteditable', function () {
        return {
        scope: {
            isolatedBindingFoo: '=bindingFoo'
        },
        require: 'ngModel',
        link: function (scope, elm, attrs, ctrl) {
            console.log('isolatedBindingFoo value is ' + scope.isolatedBindingFoo);
            // view -> model
            elm.bind('blur', function () {
            scope.$apply(function () {
                ctrl.$setViewValue(scope.isolatedBindingfoo);
            });
            });

            // model -> view
            ctrl.$render = function () {
            elm.html(ctrl.$viewValue);
            };

            // load init value from DOM
            // Why is content editable value displayed as Hello!
            // after setting view value below?
            ctrl.$setViewValue(scope.isolatedBindingFoo);
        }
        };
    });

    function ItemCtl($scope) {
         $scope.foo = 'Hello!';
    }