小编Kri*_*ons的帖子

禁止在查询参数更改时重新加载基于ui-router的视图

更新的问题

标题中的问题仍然存在 - 是否可以捕获?parameters和取消视图重新加载.

原始问题:我需要为我的应用程序添加锚点支持(主题的锚点).

这是我有多远:

angular.module('app.topics', [
    'ui.state',
    'ui.router',
    'restangular'
    'app.topics.controllers'
])
.config(function config($stateProvider) {
    $stateProvider.state('viewtopic', {
        url: '/topics/:slug?section',
        onEnter: function($stateParams) {
            // Works, as state has been reloaded.
            console.log('$stateParams', $stateParams);
        },
        resolve: {
            topic: function ($stateParams, Topic) {
                // Wrapper around Restangular. Returns promise.
                return new Topic().get($stateParams.slug);
            }
        },
        views: {
            'main': {
                controller: 'TopicCtrl',
                templateUrl: 'topics/templates/details.tpl.html'
            },
            'sidebar': {
                controller: 'SidebarCtrl',
                templateUrl: 'topics/templates/sidebar.tpl.html'
            }
        }
    });
});

angular.module('app.topics.controllers', [])
    .controller('TopicCtrl', function ($scope, topic, $rootScope, …
Run Code Online (Sandbox Code Playgroud)

anchor angularjs angular-ui-router

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

使用 utf-8 文本输入通过 shell_exec 调用程序

特权:hunspellphp5

来自 bash 的测试代码:

user@host ~/ $ echo 'sagad?j?s' | hunspell -d lv_LV,en_US
Hunspell 1.2.14
+ sagad?ties
Run Code Online (Sandbox Code Playgroud)

- 工作正常。

测试代码(test.php):

$encoding = "lv_LV.utf-8";

setlocale(LC_CTYPE, $encoding); // test
putenv('LANG='.$encoding); // and another test

$raw_response = shell_exec("LANG=$encoding; echo 'sagad?j?s' | hunspell -d lv_LV,en_US");

echo $raw_response;
Run Code Online (Sandbox Code Playgroud)

返回

Hunspell 1.2.14
& sagad 5 0: tagad, sagad?ties, sagaudo, sagand?, sagar?o
*
*
Run Code Online (Sandbox Code Playgroud)

屏幕截图(无法发布带有无效字符的代码): Hunspell php 无效字符

似乎 shell_exec 无法正确处理 utf-8,或者可能需要一些额外的编码/解码?

编辑:我必须使用 en_US.utf-8 来获取有效数据。

php shell shell-exec utf-8 hunspell

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

提交中包含gitignore设置

我正在尝试在git中提交正确的文件,但是在正确配置gitignore时遇到了问题。我按照此处的说明创建了gitignore文件(django项目):

# File types #
##############
*.pyc
*.swo
*.swp
*.swn

# Directories #
###############
logs/

# Specific files #
##################
projectname/settings.py

# OS generated files #
######################
.DS_Store
ehthumbs.db
Icon
Thumbs.db
*~
Run Code Online (Sandbox Code Playgroud)

问题是settings.py已包含在提交中:

Admin$ git add .
Admin$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   projectname/settings.py
Run Code Online (Sandbox Code Playgroud)

如何忽略gitignore中的设置?

git commit gitignore

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