Javascript 将节点webkit nwdirectory绑定到ngmodel

Javascript 将节点webkit nwdirectory绑定到ngmodel,javascript,node.js,angularjs,node-webkit,Javascript,Node.js,Angularjs,Node Webkit,Node Webkit提供了一种使用选择目录的方法,但是如何将角度模型绑定到所选文件夹 我试过: .directive("getDir", [function () { return { scope: { getDir: "=" }, link: function (scope, element, attributes) { element.bind("change", function (c

Node Webkit提供了一种使用
选择目录的方法,但是如何将角度模型绑定到所选文件夹

我试过:

.directive("getDir", [function () {
    return {
        scope: {
            getDir: "="
        },
        link: function (scope, element, attributes) {
            element.bind("change", function (changeEvent) {
                scope.$apply(function () {
                    scope.getDir = changeEvent.target.files[0]
                })
            })
        }
    }
}])
在控制器的HTML上(部分路由):

但是在选择之后,
{{location}}

  • 在html中,您需要使用破折号分隔的样式,例如,而不是
    getDir=“location”
    write
    get dir=“location”
    。请参阅以供参考
  • 您希望打印
    {{location}
    ,但在指令中,您将文件目标的值分配给
    scope.getDir
    ,因此可以使用与{{getDir}相同的变量名打印它
  • 请签入固定代码

    {{ location }}
    
    <div class="uk-form-file">
        <button class="uk-button">New Location</button>
        <input type="file" getDir="location" nwdirectory>
    </div>
    
    .controller('HomeCtrl', function($scope) {
    
    })