我有一个使用UI路由器的Angular应用程序,我试图在应用程序运行时验证用户的令牌(如果存在).我还检查用户是否有权访问某些路线.问题是$stateChangeStart在我从授权端点收到响应之前正在运行.这是一些代码(coffeescript与js下面) - 这都在我的run块内.
app.run(($rootScope, $state, $stateParams, $log, Auth) ->
currentState = 'home'
$rootScope.$state = $state
# read a cookie if cookie exists
if Auth.setAuthenticationToken()
# hit api endpoint to validate token
Auth.validateToken (user) ->
# route to current state
# this returns after $stateChangeStart runs below
$state.go(currentState)
$rootScope.$on '$stateChangeStart', (event, toState, toParams, fromState, fromParams) ->
currentState = toState.name
Auth.setAuthenticationToken()
$rootScope.error = null
# compare users access permissions with incoming route's access level
if (!Auth.authorize toState.data.access, Auth.user) …Run Code Online (Sandbox Code Playgroud) javascript authorization coffeescript angularjs angular-ui-router
更少的问题是如何以及更多的问题...我试着搜索一些并且找不到我想要的答案.
我很好奇为什么IE中存在条件评论?微软是否将其实施到不同的浏览器版本中,因为他们知道它们不符合标准?
我知道其他浏览器的某些版本可以使用条件注释进行定位,但IE的远远超过任何其他浏览器.
我有兴趣听取有关条件评论的起源和历史的任何信息.
我正在redux-form尝试创建一个导致对象数组的表单,例如:
const formData = {
//...
rules: [
{
level: 1,
source: 'some source',
//...
}, {
level: 3,
source: 'another source'
//...
}
]
}
Run Code Online (Sandbox Code Playgroud)
看起来我应该能够FormSection使用FieldArray组件来下一个多个...但我无法使它工作.这是我目前的尝试:
const renderRules = ({ fields, meta: { error } }) => (
<div>
<Button
text="Add Rule"
onClick={e => {
e.preventDefault()
fields.push()
}}
/>
{fields.map((rule, index) => (
<FormSection name="rule"} key={index}>
<legend>Rule {index + 1}</legend>
<Field name="level" component={Select} label="Level">
<Option value={1}>Level 1</Option>
<Option value={2}>Level 2</Option>
<Option value={3}>Level 3</Option> …Run Code Online (Sandbox Code Playgroud) javascript ×2
angularjs ×1
browser ×1
coffeescript ×1
comments ×1
css ×1
forms ×1
html ×1
reactjs ×1
redux ×1
redux-form ×1