2017-01-12 3 views
0

私のアプリに問題があります。 grunt serveでビルドすると、すべて正常に動作しますが、distにビルドしようとすると、コンポーネントのバインディングが何とか失敗しているようです。コードは次のようなものになります。しかし、私はgruntさんdistのそれにログに記録された値を見るとAngularJSコンポーネントのバインディングは、縮小時に定義されていません

angular.module('jsonParserApp') 
.component('leafTemplate', { 
    templateUrl: 'views/itemList.html', 
    bindings: { 
    readonly: '<', 
    //other bindings (works properly) 
    }, 
    controller: ['$scope', 'copiedValue', function($scope, copiedValue) { 
    //code 
    this.$onChanges = function(changesObj) { 
     console.log('onChanges', changesObj); 
    //code 
    }; 
    //code 
    }] 
}); 

をそして、私はconsole.logctrl.readonly の値が何であるかをチェックするとき、それは

{ 
    "readonly": { 
    "currentValue": true, 
    "previousValue": UNINITIALIZED_VALUE 
    } 
} 

を返します。戻る

{ 
    "readonly": { 
    "currentValue": undefined, 
    "previousValue": UNINITIALIZED_VALUE 
    } 
} 

重要なことは、このコンポーネントが再帰的に構築される。 HTMLでそのコードは、多かれ少なかれ、このようになります。あるべきコードの

<ul ng-show="main.toggleInputTree" class="overflow-auto" flex> 
    <li ng-repeat="(key, value) in main.inputJson"> 
    <leaf-template k="key" t="main.inputJson" i="{{$index}}" readonly="true" parent="$"></leaf-template> 
    </li> 
</ul> 

(第2のサンプル(コードの最初のサンプルは、trueまたはfalseに読み取り専用値を初期化し、それが子要素に伝播する必要があります)値が縮小さ/ uglifiedバージョンに伝播されない理由は、問題となっているものではありません)

<ul ng-show="ctrl.displayChildren" ng-if="!ctrl.isString(ctrl.t, ctrl.k)"> 
    <li ng-repeat="(key, value) in ctrl.t[ctrl.k]"> 
    <leaf-template k="key" t="ctrl.t[ctrl.k]" i="{{$index}}" readonly="ctrl.readonly" parent="{{ctrl.parent + '.' + ctrl.k}}"></leaf-template> 
    </li> 
</ul> 

からgrunt serveにその作業、gruntのdistの上 - それから伝播親ですか?

@UPDATE

私はそれをデバッグしようとしたと私は非常に面白いものを見つけました。構築する前に、HTMLは次のようになります。

<leaf-template k="key" t="ctrl.t[ctrl.k]" i="{{$index}}" readonly="ctrl.readonly" parent="{{ctrl.parent + '.' + ctrl.k}}"></leaf-template> 

とdistのバージョンの中に、いくつかの理由から、この

<leaf-template k="key" t="main.inputJson" i="{{$index}}" readonly parent="$"></leaf-template> 

のように見える$ templateCacheホールドHTMLは、readonly="ctrl.readonly"readonly

+0

問題を解決した場合は、質問に答えてください。そうすれば、他の人は問題が解決されたことを知ることができます。また、あなたは答えを受け入れることで自分自身のポイントを与えることができます。 :-) – georgeawg

+0

アドバイスありがとうございます。 :) –

答えて

0

変更名にカットされますreadonlyから他に助けられました...実際にはreadonlyはHTML入力の属性なので、urglifyはreadonly="ctrl.readonly"readonlyに解析しました。

関連する問題