我有这条路线:
Sub TXTconvertXLS()
'Variables
Dim wb As Workbook
Dim strFile As String
Dim strDir As String
Application.ScreenUpdating = False
'Directories
strDir = 'path went here
strFile = Dir(strDir & "*.txt")
Do While strFile <> ""
Set wb = Workbooks.Open(strDir & strFile)
With wb
.SaveAs Replace(wb.FullName, ".txt", ".xls"), 50
.Close False '<-already saved in the line directly above
End With
Set wb = Nothing
strFile = Dir '<- stuffs the next filename into strFile
Loop
Application.ScreenUpdating = True
End Sub
我有这个组件绑定def:
{
name : 'myPage',
url : '/myPage',
views: {
'@': {
component: components.MyComponent.name
}
},
params: {
turtle: {y: 2}
},
resolve : {
turtle: function($stateParams) {
window.turtle = $stateParams.turtle;
window.daaa = $stateParams;
return $stateParams.turtle;
}
}
}
和MyComponent控制器的构造函数:
bindings: {
turtle: '<'
}
打印:
class MyComponentController {
let self = this;
this.$onInit = function() {
console.log("-----")
console.log("window.turtle: " + JSON.stringify(window.turtle))
console.log("self.turtle: " + JSON.stringify(self.turtle))
console.log("window.turtle == self.turtle: " + (window.turtle == self.turtle))
console.log("window.turtle == self.$stateParams.turtle: " + (window.turtle == self.$stateParams.turtle))
console.log("window.daaa == self.$stateParams: " + (window.daaa == self.$stateParams))
console.log("-----")
}
}
这对我来说真的很奇怪......让我觉得一旦你进入一个状态,UI路由器会复制$ stateParams(所以你在解决方案中看到$ stateParams!= $ stateParams你在控制器中看到了...... 和它还复制了每个声明的参数(深度克隆???)。
我没想到。这是一个错误吗?或功能(可能是保护机制?)。谁是罪魁祸首? UI路由器?或者是角度为1.5的组件(带有隔离范围的东西)?
先谢谢你帮我澄清一下。
答案 0 :(得分:1)
根据ui-router source code(由Daniel here链接)$stateParams
已被弃用,建议使用$transition$
注入(请参阅{{3上的ui-router文档) }})
以下是在解析函数中使用它的示例:
$stateProvider.state('a-route', {
// ...
// define params for route
params: {
data: null
},
// set up data to resolve to params.data
resolve: {
data: ($transition$) => {
return $transition$.params().data;
}
}
})
请看这里的工作示例: $transition$
注意:文档还声称可以将$transition$
注入控制器,但我无法使其工作,因此使用了解析fn。