我正在尝试使用AngularJS更改URL,但不是使用重定向,只需在事件后更改URL.
我需要的是这个:
www.myurl.com/inbox/1 对此 www.myurl.com/inbox/25
换句话说,只需更改最后一个ID.
我正在尝试这样做:
$location.path('/inbox/'+id);
但我得到的是这个:
www.myurl.com/inbox/1#/inbox/25
我需要在输入中捕获用户的退格.
所以我做到了这一点:
<input type="text" ui-keypress="{8:'removeTagOnBackspace()'}" ng-model="searchStudent" />
Run Code Online (Sandbox Code Playgroud)
然后,在我的控制器里面我做了这个,只是为了检查它是否正常工作:
$scope.removeTagOnBackspace = function() {
console.log('here');
};
Run Code Online (Sandbox Code Playgroud)
但是不打印任何东西.这有什么问题?角度是否能够捕获退格?
我是用我的代码将我的JavaScript文件与React Router和Webpack 2分开:
export default {
path: '/',
component: Container,
indexRoute: {
getComponent(location, cb) {
if (isAuthenticated()) {
redirect();
} else {
System.import('../landing-page/LandingPage')
.then(loadRoute(cb))
.catch(errorLoading);
}
},
},
childRoutes: [
{
path: 'login',
getComponent(location, cb) {
System.import('../login/Login')
.then(loadRoute(cb))
.catch(errorLoading);
},
},
{ /* etc */
}
};
Run Code Online (Sandbox Code Playgroud)
这个捆绑包的结果如下:
public/
vendor.bundle.js
bundle.js
0.bundle.js
1.bundle.js
2.bundle.js
Run Code Online (Sandbox Code Playgroud)
这意味着最终用户只能获得他/她所需的JavaScript,根据他/她所处的路线.
问题是:对于css部分,我找不到任何资源来做同样的事情,即根据用户的需要拆分CSS.
有没有办法用Webpack 2和React Router做到这一点?
我试图用npm运行的任何命令我得到:
module.js:340
throw err;
^
Error: Cannot find module 'balanced-match'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/glob/node_modules/minimatch/ node_modules/brace-expansion/index.js:2:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Run Code Online (Sandbox Code Playgroud)
包括当我尝试时 npm install -g balanced-match
CircleCI 有一个CIRCLE_BRANCH环境变量,它告诉您 PR 本身的分支名称。
但我想要相反,我需要 PR 试图合并的分支名称。
我有一个使用Webpack的生成版本,它使用节点process.env来设置环境变量:
webpack.prod.babel.js:
const DefinePlugin = new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
API_URL: JSON.stringify('https://myprodurl.com'),
},
});
Run Code Online (Sandbox Code Playgroud)
packge.json:
"scripts: {
"build:prod": "webpack"
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但我需要不同的东西.
我需要在NPM脚本中将生产URL设置为变量.
所以,而不是这个:
npm run build:prod
Run Code Online (Sandbox Code Playgroud)
我需要这个:
npm run build:prod --URL https://myprodurl.com
Run Code Online (Sandbox Code Playgroud) 我正在使用FactoryAngularJS,这是这样的:
if (href) {
return $http({ method: method, url: item.href });
}
else {
// needs to return a failed promise
}
Run Code Online (Sandbox Code Playgroud)
因此,如果条件为真,那么我需要做的就是调用$http承诺,这意味着谁在使用我的工厂正在期待一个承诺.问题是:如果条件为假,我需要返回被拒绝的承诺.有没有办法做到这一点?
谢谢!
我有一个方法叫做$scope.openGroupInbox()哪个$scope.init()和其他东西.我想测试是否$scope.init()已被调用.所以我这样做:
it('call init', function () {
$scope.openGroupInbox(3);
expect($scope.init(3)).toHaveBeenCalled();
});
Run Code Online (Sandbox Code Playgroud) 我的组件中需要一个超时内的setState,所以我这样做了:
componentDidMount() {
this.timeouts.push(setTimeout(() => {
this.setState({ text: 2 });
}, 4000));
}
componentWillUnmount() {
this.timeouts = [];
}
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误:
Warning: setState(...): Can only update a mounted or mounting component.
This usually means you called setState() on an unmounted component.
This is a no-op.
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我有这个代码:
public IHttpActionResult Get([FromUri]GetFilesRequest request)
Run Code Online (Sandbox Code Playgroud)
如果request为null,我想创建一个新的GetFilesRequest,因为在构造函数中我这样做是为了创建类的默认参数:
public GetFilesRequest()
{
Sort = "latest";
Filter = "";
}
Run Code Online (Sandbox Code Playgroud)
所以我在考虑:
public IHttpActionResult Get([FromUri]GetFilesRequest request = new GetFilesRequest)
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个警告:
'request' is of type 'GetFilesRequest'. A default parameter value of a reference type other than string can only be initialized with null.
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Lua Socket 进行 http get:
local client = socket.connect('warm-harbor-2019.herokuapp.com',80)
if client then
client:send("GET /get_tweets HTTP/1.0\r\n\r\n")
s, status, partial = client:receive(1024)
end
end
Run Code Online (Sandbox Code Playgroud)
我希望s是一条推文,因为我所做的 get 返回一条推文。但我得到:
http/1.1 404 object not found
Run Code Online (Sandbox Code Playgroud) 我有这张桌子:
StudentId | ConfigurationTypeId
1 | 1
1 | 2
1 | 3
2 | 1
2 | 2
Run Code Online (Sandbox Code Playgroud)
我想删除此表中的所有记录 ConfigurationTypeId = 3
所以我提出了这个问题:
DELETE FROM [StudentConfigurationType] WHERE StudentId IN
(SELECT StudentId FROM [StudentConfigurationType] SCT
INNER JOIN [Student] S ON S.Id = SCT.StudentId
WHERE SCT.ConfigurationTypeId = 3 AND S.RegisteredDate < '2014-09-18')
Run Code Online (Sandbox Code Playgroud)
但是,因为这个表没有Id,所以StudentId会进来,它会从表中删除所有记录.怎么能做这样的事情:
DELETE FROM [StudentConfigurationType] WHERE StudentId AND ConfigurationTypeId IN
(SELECT StudentId, ConfigurationTypeId FROM [StudentConfigurationType] SCT
INNER JOIN [Student] S ON S.Id = SCT.StudentId
WHERE SCT.ConfigurationTypeId = 3 AND S.RegisteredDate …Run Code Online (Sandbox Code Playgroud) angularjs ×4
node.js ×2
npm ×2
reactjs ×2
webpack ×2
angular-ui ×1
asp.net ×1
c# ×1
circleci ×1
circleci-2.0 ×1
components ×1
css-modules ×1
delete-row ×1
jasmine ×1
javascript ×1
keypress ×1
location ×1
lua ×1
luasocket ×1
npm-scripts ×1
sockets ×1
sql ×1
sql-delete ×1
sql-server ×1
url ×1
webpack-2 ×1