支持文本值缺省值的处理
This commit is contained in:
parent
7c9ddc5f36
commit
bec53420c1
|
@ -0,0 +1,9 @@
|
|||
@app.directive 'ngInitial', ->
|
||||
restrict: 'A',
|
||||
controller: [
|
||||
'$scope', '$element', '$attrs', '$parse', ($scope, $element, $attrs, $parse)->
|
||||
val = $attrs.ngInitial || $attrs.value || $attrs.$$element.text()
|
||||
getter = $parse($attrs.ngModel)
|
||||
setter = getter.assign
|
||||
setter($scope, val)
|
||||
]
|
|
@ -8,9 +8,8 @@
|
|||
= f.input :type, :as=>:select, :collection=> [ Post::TECH, Post::LIFE, Post::CREATOR ], label: '类别', "ng-model"=>"type", input_html: { name: 'type' }
|
||||
.row
|
||||
.small-12.large-6.columns
|
||||
= f.simple_fields_for :label do |p|
|
||||
= label_tag :labels, '标签'
|
||||
= text_field_tag :labels, nil, "ng-model"=>"labels"
|
||||
= text_field_tag :labels, @post.labels_content(true), "ng-model"=>"labels", "ng-initial" => ''
|
||||
|
||||
.row
|
||||
.small-12.columns
|
||||
|
@ -30,7 +29,7 @@
|
|||
input[type="file" style="display: none;"]
|
||||
|
||||
.content-field ng-show="body_active" ng-model= 'content'
|
||||
= f.input :content, :as=> :text, :label => false, input_html: { name: 'content', "ng-model"=>'content' }
|
||||
= f.input :content, :as=> :text, :label => false, input_html: { name: 'content', "ng-model"=>'content', 'ng-initial'=>'' }
|
||||
|
||||
.preview.markdown ng-hide="body_active" ng-bind-html=" previewHTML "
|
||||
|
||||
|
|
Loading…
Reference in New Issue