Working with select using AngularJS's ng-options

前端 未结 8 915
渐次进展
渐次进展 2020-11-22 08:30

I have read about it in other posts, but I couldn\'t figure it out.

I have an array,

$scope.items = [
   {ID: \'000001\', Title: \'Chicago\'},
   {ID         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 08:45

    In CoffeeScript:

    #directive
    app.directive('select2', ->
        templateUrl: 'partials/select.html'
        restrict: 'E'
        transclude: 1
        replace: 1
        scope:
            options: '='
            model: '='
        link: (scope, el, atr)->
            el.bind 'change', ->
                console.log this.value
                scope.model = parseInt(this.value)
                console.log scope
                scope.$apply()
    )
    
    
    
    
    
    
    
    
    

    Sometimes it's much easier to create your own directive...

提交回复
热议问题