小编use*_*987的帖子

angularjs + ui.bootstrap分页错页总页数

无法评论主帖,所以需要发帖新问题.

我正在尝试从Scotty.NET(评价最高的答案)编写的这个帖子中实现分页解决方案,但面临一个奇怪的问题:

我的自定义代码在此plunker(http://plnkr.co/edit/Mdsy2x)中并解释了该问题.如果我设置$scope.numPerPage为除"10"之外的任何数字 - 我的总页数会出错.例如,如果我生成450 todo并且设置$scope.numPerPage = 5;- 我总共得到45页并显示225项,因此除了10之外的任何数字都会给出错误的结果

pagination twitter-bootstrap angularjs

3
推荐指数
1
解决办法
4567
查看次数

pytest"没有模块命名"错误

我是python的新手,并试图为我的第一个应用程序编写测试.简单的app结构:

- app
      - tests
        __init__.py
        - test_main.py
      - __init__.py
      - main.py
Run Code Online (Sandbox Code Playgroud)

main.py包含 main_func

test_main.py:

from main import main_func

def test_check():
    assert main_func() is True
Run Code Online (Sandbox Code Playgroud)

如果我pytestapp目录中手动运行测试- 得到此错误:

C:\Users\*****\PycharmProjects\checker3>pytest
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
rootdir: C:\Users\*****\PycharmProjects\app, inifile:
collected 0 items / 1 errors 

=================================== ERRORS ====================================
_____________________ ERROR collecting tests/test_main.py _____________________
ImportError while importing test module 'C:\Users\*****\PycharmProjects\app\tests\test_main.py'.
Original error message:
'No module named 'main''
Make sure …
Run Code Online (Sandbox Code Playgroud)

python pytest pycharm

3
推荐指数
1
解决办法
6852
查看次数

Google Chrome开发者工具可模拟拖放事件

问题很简单,但无法真正找到答案.

如何使用chrome开发人员工具模拟拖放事件

确定我可以手动拖放文件,但我无法检查DOM中的更改.

javascript google-chrome google-chrome-devtools

2
推荐指数
1
解决办法
2093
查看次数

响应对象中的Angular 4打字稿解析枚举接口属性

我有一个来自API的响应,该响应返回一个枚举值。从API返回的值在请求中表示为字符串。该值是enum打字稿界面的属性。

问题: 当收到响应时,TS接口将该值存储为字符串(可能就是问题所在),因此我不能将其直接用作enum

obj模型:

export interface Condo {

  id:number
  title:string
  latitude:number
  longitude:number

  city:string
  country:string
  district:string
  address:string
  locationType: LocationType
}

export enum LocationType {
  CONDO,
  MALL,
  STATION
}
Run Code Online (Sandbox Code Playgroud)

请求:

getCondoAllByCountry(country_code){
    return this.http.get(this.config.apiEndpoint +this.subApiUrl+'/all')
      .map(res => <Condo[]>res.json())
      .catch((err:Response) => {
        return Observable.throw(err.json());
      });
    }
Run Code Online (Sandbox Code Playgroud)

用法样本:

    this.condoService.getCondoAllByCountry(this.userData.country_code).subscribe(data=>{
          someFunc(data)
        })

............
    someFunc(condo_list: Condo[]){
    //here is need to know the `locationType` for each object
      console.log(typeof condo_list[i].locationType);
      console.log(typeof LocationType.CONDO)
      switch (condo_list[i].locationType){
        case LocationType.CONDO:
          console.log('Case - condo')
          break;
        case LocationType.MALL:
          console.log('Case - mall') …
Run Code Online (Sandbox Code Playgroud)

typescript ionic2 angular

2
推荐指数
1
解决办法
3173
查看次数

django休息单线程/阻塞视图

在单个用户执行视图时,是否可以阻止访问视图的所有用户执行视图中的代码?一种单线程视图.

我需要它,因为我pyinstaller在此视图中生成python可执行文件,并通过配置文件将用户名传递给可执行文件.

例如:

class CliConfig(APIView):

    def get(self, request, format=None):
        try:
            config['DEFAULT']['username'] = request.user

            #make a build with pyinstaller
            bin_file = open(*generated filepath *, 'rb')
            response = Response(FileWrapper(bin_file), content_type='application/octet-stream')
            response['Content-Disposition'] = 'attachment; filename="%s"' % '*filename*'
            return response
        finally:
            config['DEFAULT']['username'] = ''
Run Code Online (Sandbox Code Playgroud)

所以,基本上我想要的是生成一个python可执行文件,它将在django rest framwork中设置一个唯一的用户名APIView.除了通过设置文件传递用户名之外,我没有看到其他方法.如果有办法 - 会赞赏建议.

python 3.6.5,djangorestframework==3.8.2,pyinstaller==3.3.1

python django pyinstaller python-3.x django-rest-framework

1
推荐指数
1
解决办法
347
查看次数

Spring使用@Autowired字段而不是@Component

我的应用程序中有一个案例,我需要使用该对象AccountsDao accountsDao

public class Account {

    @Autowired
    private AccountsDao accountsDao;
Run Code Online (Sandbox Code Playgroud)

无需将属性添加@ComponentAccount类中(并且无需任何其他方法将其标记为 spring bean)。

app很大,有客观原因Account不能是Spring Bean,必须手动初始化。

我也知道这是单例,通用结构就可以了。

有没有办法做到这一点?

java spring spring-mvc

0
推荐指数
1
解决办法
4251
查看次数