我正在尝试通过ajax
将项目加载到selectize.js
,但似乎无效。
Api工作正常,调用success方法但它不呈现任何项目,并且它不会输出render方法中给出的控制台。
这是它的样子(coffeescript)
FindUserDirective = ($http)->
options =
restrict: 'A'
replace: false
scope: true
link: (scope, element, attrs)->
$(element).selectize
valueField: 'firstName'
labelField: 'firstName'
searchField: 'firstName'
create: false
render: option: (user, escape)->
console.log user
"<div>#{user.fullName}</div>"
load: (query, callback)->
if not query.length then callback()
url = Routing.generate('api_cget_client', {uuid:config.studio.uuid})
$http
.get url
.then(
# on success
(response)->
callback response.data.users
# this gives a beautiful array with users
,
# on error
(response)->
callback()
)
options
application
.directive('finduser' , FindUserDirective)
任何想法?