小编Jér*_*émy的帖子

$(document).ready 替代 AngularJS

我正在使用一个名为 Gentelella 的模板,我正在尝试在其中实现 AngularJS。但是,我遇到了某个 Javascript 文件的问题。在该文件的末尾,$(document).ready调用了一个函数来初始化 Javascript 代码,从而对 HTML 代码进行一些更改。问题是该$(document).ready函数在 HTML 完全加载之前被调用得太早。

出现这个问题可能是因为我使用了 ngRoute,这会将模板 html 文件注入到 index.html 的 ng-view 中。发生这种情况时,DOM 可能已经在 AngularJS 注入模板 (=HTML) 之前宣布准备好文档。

所以基本上,一旦 AngularJS 注入模板,我只需要找到一种方法来调用 Javascript 文件中的一些代码。

我附上了一些代码来深入了解这个问题:

custom.min.js 的片段

$(document).ready(function () {
  init_sparklines(), init_flot_chart(), init_sidebar(), init_wysiwyg(), init_InputMask(), ...
});
Run Code Online (Sandbox Code Playgroud)

main.js 的片段:

.config(function($routeProvider, $httpProvider) {

  $routeProvider.when('/', {
    templateUrl : 'dash.html',
    controller : 'dash',
    controllerAs: 'controller'
  }).when('/login', {
    templateUrl : 'login.html',
    controller : 'navigation',
    controllerAs: 'controller'
  }).when('/plain_page', {
    templateUrl : 'plain_page.html',
    controller : 'dash', …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery angularjs gentelella

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

如果单选按钮.is(':选中') - 无法正常工作

我有一个javascript代码,用于在检查单选按钮时显示字段.代码工作正常,但是当我取消选中收音机时,该字段不会隐藏.它还会显示<span>选中单选按钮的时间,但是当未选中时,跨度也不会隐藏..

<script>
$(function() {
    $('#radiopromo2').live('change', function() {
        if($(this).is(':checked')) {
            $("#fieldtraining").show();
            $("#radio3").show();
        } else {
            $("#fieldtraining").hide();
            $("#radio3").hide();
        }
    }).trigger('change');
});
</script>
Run Code Online (Sandbox Code Playgroud)

谁可以帮助我?我做了一个jsfiddle http://jsfiddle.net/4UH2H/8/

html javascript jquery input radio-button

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

C#中索引器的快捷方式

我在C#中的类中使用了一个索引器,但我想知道默认情况下是否有用于制作索引器的快捷方式(例如' cwtab tab' Console.WriteLine()).有谁知道这是否存在?

这是"Person"类的代码(带索引器):

public string SurName { get; set; }
public string FirstName { get; set; }
public string Birthplace { get; set; }

public string this[int index]
{
    set
    {
        switch (index)
        {
            case 0:
                this.SurName = value;
                break;
            case 1:
                this.FirstName = value;
                break;
            case 2:
                this.Birthplace = value;
                break;
            default:
                throw new ArgumentOutOfRangeException("index");
        }
    }
    get
    {
        switch (index)
        {
            case 0: return this.SurName;
            case 1: return this.FirstName;
            case 2: return this.Birthplace;
            default: …
Run Code Online (Sandbox Code Playgroud)

c# indexer visual-studio

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

Javascript jQuery在打开页面时隐藏字段

我有以下代码:

<script>
    $('#advert').live('change', function () {
        if ($(this).is(':checked')) {
            $(":text").show();
        } else {
            $(":text").hide();
        }
    });
</script>
Run Code Online (Sandbox Code Playgroud)

选中复选框后,此代码显示和隐藏文本字段.它工作得很好,但我想在页面打开时隐藏文本字段.

javascript forms jquery input

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

PHP strtotime有多个变量

这是我的PHP代码:

$timestamp2 = strtotime('13:30 04/12/2013');
Run Code Online (Sandbox Code Playgroud)

但是,我想将这些变量放在这段代码中:

        $mi = mysql_real_escape_string($_POST['mi']);
        $ho = mysql_real_escape_string($_POST['ho']);
        $da = mysql_real_escape_string($_POST['da']);
        $mo = mysql_real_escape_string($_POST['mo']);
        $ye = mysql_real_escape_string($_POST['ye']);
Run Code Online (Sandbox Code Playgroud)

例如:

$timestamp2 = strtotime('$mi:$ho $mo/$da/$ye');
Run Code Online (Sandbox Code Playgroud)

我已经尝试了多种可能的引号等等.但它没有任何成功.有人可以帮我弄这个吗?

谢谢!

php variables time date strtotime

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