我有这种状态:
.state('admin.category',{
url: '/category',
templateUrl:'views/admin.category.html',
resolve:{
category: ['CategoryLoader', function(CategoryLoader){
return new CategoryLoader();
}]
},
})
Run Code Online (Sandbox Code Playgroud)
这是我所解决的服务。
.factory('CategoryLoader',['Category', '$state', '$q',
//console.log($state)
function(Category, $state, $q){
return function(){
var delay = $q.defer();
Category.get({cat_id:$state.params.id}, //not working
function(category){
delay.resolve(category);
},
function(){
//delay.reject('Unable to fetch category ' + $state.params.cat_id)
});
return delay.promise;
}
}]);
Run Code Online (Sandbox Code Playgroud)
如果将$ state.params.id更改为数字,则一切正常。如果在服务中管理$ state,我将获得所有信息,包括参数。但我似乎无法使用它。使用我在其他项目中使用过的$ route.current.params.id应该是等效的。我如何使用ui-router做同样的事情?
更新:更多信息
父状态:
.state('admin',{
abstract: true,
url: '/admin',
templateUrl:'views/admin.html'
})
Run Code Online (Sandbox Code Playgroud)
类别工厂:
factory('Category', function($resource){
return $resource('/api/category/byId/:id/', {id: '@id'});
})
Run Code Online (Sandbox Code Playgroud)
如果需要的话,我会摆一个小提琴
我有一个切换管理员和客户端模式的按钮.我把它放在了rootcope上,所以我可以随处访问它.
我正在使用angular-ui directive
切换.
我已经看了这个型号.但什么都没发生.知道什么可能是错的吗?
.run(['$rootScope', '$state', '$stateParams', '$location',
function ($rootScope, $state, $stateParams, $location) {
$rootScope.projectMode = 'Client';
$rootScope.$watch('projectMode', function(){
var path = $location.path();
alert("fire") //Only fire ones when the app starts
if($rootScope.projectMode === 'Client'){
var current = 'client'
var replace = 'admin'
} else {
var current = 'admin'
var replace = 'client'
}
var newUrl = path.replace(current, replace)
$location.url(newUrl);
})
}])
Run Code Online (Sandbox Code Playgroud)
这是我的看法.
<div class="btn-group">
<button type="button" class="btn btn-default" ng-model="projectMode" btn-radio="'Client'">Klient</button>
<button type="button" class="btn btn-default" ng-model="projectMode" btn-radio="'Admin'">Admin</button>
</div> …
Run Code Online (Sandbox Code Playgroud) var person = {
name: 'Joe',
contact: {
phone: '555'
}
}
var nameOfPerson = person['name']; //Joe
var str = 'contact.phone';
var phoneToPerson = person[str]; //undefined
Run Code Online (Sandbox Code Playgroud)
这有可能以某种方式吗?我有一些逻辑,我最终得到一个字符串,我需要使用它访问嵌套属性.
眼镜:
这是我迄今为止所拥有的: ^[a-zA-Z0-9]{0,5}$
'AV'
例如,我有这个接受的问题。它必须包含一个数字才有效。
已启用 Azure 应用程序见解。https://learn.microsoft.com/en-us/azure/azure-monitor/app/nodejs
想要记录我的 Express Node JS 应用程序的输出:
GET /api/loggedin 304 6.377 ms - -
GET /api/xx 304 31.052 ms - -
hello // a console.log
GET /api/loggedin 304 5.127 ms -
Run Code Online (Sandbox Code Playgroud)
在哪里可以看到console.log数据?找不到它。
使用这个https://github.com/gregnb/react-to-print
打印时,我在 Chrome 打印对话框中没有方向属性。
如您所见,我有一个包含许多列的表。横向方向将是首选。
Chrome 在什么情况下会隐藏此功能?是一些 html 元素触发了这个吗?
得到这种类型的字符串:
var myString = '23, 13, (#752, #141), $, ASD, (#113, #146)';
Run Code Online (Sandbox Code Playgroud)
我需要将其拆分为数组,并使用逗号作为分隔符,但也转换(..)
为数组.
这是我想要的结果: [23, 13, ['#752', '#141'], '$', 'ASD', ['#113', '#146']];
我拥有庞大的数据集,因此尽可能快地实现它是非常重要的.什么是最快的方式?做一些RegExp功能或手动查找索引等吗?
我的管道在位桶中:
- pipe: microsoft/azure-cli-run:1.0.2
variables:
AZURE_APP_ID: $AZURE_APP_ID
AZURE_PASSWORD: $AZURE_PASSWORD
AZURE_TENANT_ID: $AZURE_TENANT_ID
Run Code Online (Sandbox Code Playgroud)
哪里AZURE_APP_ID
?在 Azure -> 应用服务上,我可以看到一个包含我的应用程序的表,但没有应用程序 ID。密码是什么?我没有在任何地方设置密码。和tenant id
?
FileReader
我有一个网络应用程序,它通过API 的方法对大文本文件(> 500mb)进行一些处理readAsText()
。
多年来它一直运行良好,但突然我得到了空响应:event.target.result
是一个空字符串。
369MB 可以工作,但 589MB 不行。
我在多台电脑上测试过;结果相同,但它在 Firefox 中确实有效。Chrome 肯定在最近的更新中引入了这一点。
这个bug已经提交了吗?
有什么解决方法吗?
谷歌表示,这应该添加到“转换页面”的 html 中。
<!-- Event snippet for Website lead conversion page --> <script> gtag('event', 'conversion', {'send_to': 'AW-sdad/-dsafdsa'}); </script>
Run Code Online (Sandbox Code Playgroud)
我有一个 ReactJS 应用程序,所以我没有单个 html“转换页面”。
我可以以某种方式从 javascript 运行它吗?
createAccount = () => {
Axios.post(`/api/signup`, { user })
.then(async (resp) => {
await Axios.post("/api/login", { email: this.state.email, password: this.state.password });
this.props.history.push("/app");
// Run google ad convert here?
})
.catch((err) => {
console.log(err);
});
};
Run Code Online (Sandbox Code Playgroud) javascript ×4
angularjs ×2
azure ×2
reactjs ×2
regex ×2
arrays ×1
filereader ×1
html ×1
logging ×1