Fill the from with model

This commit is contained in:
Bing Xie
2016-08-05 20:04:41 +10:00
parent 5b40c745f3
commit 45e3f8ab3a
2 changed files with 19 additions and 11 deletions

View File

@@ -1,13 +1,21 @@
angular.module("admin.customers").directive 'editAddressDialog', ($compile, $templateCache, DialogDefaults, CurrentShop, Customers) ->
angular.module("admin.customers").directive 'editAddressDialog', ($compile, $templateCache, $filter, DialogDefaults, Customers) ->
restrict: 'A'
scope: true
link: (scope, element, attr) ->
scope.$watch 'country', (newVal) ->
scope.$watch 'address.country_id', (newVal) ->
if newVal
scope.states = newVal.states
scope.states = scope.filter_states(newVal)
scope.updateAddress = ->
console.log(scope.edit_address_form)
template = $compile($templateCache.get('admin/edit_address_dialog.html'))(scope)
template.dialog(DialogDefaults)
element.bind 'click', (e) ->
scope.address = scope.customer.bill_address
template.dialog('open')
scope.$apply()
scope.filter_states = (countryID) ->
$filter('filter')(scope.availableCountries, {id: countryID})[0].states