这是一个快速的问题:
是否有可能拥有一个模板,其中您有多个模板并在需要时调用您需要的模板?
让我更好地解释一下:
我有一个我这样称呼的模态:
$scope.showErrorModal = ->
errorModal = $ionicPopup.show(
title: 'Issues list'
scope: $scope
templateUrl: './sections/modal/modal.tpl.html'
buttons: [{text: 'Close',type: 'button-assertive'}
])
errorModal.then (res) ->
console.log 'tapped!', res
return
return
如您所见,我使用的是外部模板。
问题是,每次我的模态需要更改时,我都需要创建不同的模板。
我想做的(如果可能的话)是能够在内部创建各种子模板modal.tpl.html
并以正确的模式调用它们。
这是一些示例代码:
modal.tpl.html:
<div id="error-template">
// here the error-modal stuff
</div>
<div id="success-template">
// here the success-modal stuff
</div>
并从控制器中,像这样调用它们,例如:
$scope.showErrorModal = ->
errorModal = $ionicPopup.show(
title: 'Issues list'
scope: $scope
templateUrl: './sections/modal/modal.tpl.html#error-template' //Just to make it clear that i want to use only one part of that file
buttons: [{text: 'Close',type: 'button-assertive'}
])
errorModal.then (res) ->
console.log 'tapped!', res
return
return
这是纯粹的虚构,还是有可能?是否有其他解决方案可以解决此类问题?