2016-10-31 8 views
0

を生成私は、次のディレクティブを有する:入力タイプ番号が文字列

<!-- directive --> 
angular.module('app', []) 
    .controller('MainCtrl', function($scope) {}) 
    .directive('test', function() { 
    return { 
     restrict: 'E', 
     link: function(scope) { 
     scope.value = 0; 
     scope.type = 'number'; 
     }, 
     templateUrl: 'template.html' 
    } 
    }); 

<!-- template --> 
<label>{{ type }}: <!--type == 'number' --> 
    <!-- produces strings --> 
    <input type="{{type}}" ng-model="value" class="form-control" /> 
    <!-- produces integers --> 
    <input type="number" ng-model="value" class="form-control" /> 
</label> 
<div>{{ value |json }}</div> 


<!-- usage --> 
<test /> 

最初の入力プログラムボックスは文字列と2番目の整数を生成します。私の意見では、そのバグです。どのような考えや回避策ですか?ここで

それを再現するplunker:レナート

+0

あなたは 'element.type'で変更しようとしましたか? – mojarras

+0

はい、同じ問題です。 – leNerd42

+0

コードを変更して、それをより明確にしました。何が起こるのですか。 – leNerd42

答えて

関連する問題