小编gio*_*_13的帖子

使用Angulartics与AngularJS的注射器错误

我有添加Angulartics的问题.

在我的app.js中,我刚刚添加了两个依赖项(Angulartics和最后一个),你可以看到:

var smsApp = angular.module('smsApp', [
  'ngRoute',
  'smsControllers',
  'smsFilters',
  'google-maps',
  'pascalprecht.translate',
  'angulartics',
  'angulartics.google.analytics',
]);
Run Code Online (Sandbox Code Playgroud)

然后在我的index.html中我添加了:

<script src="./js/angulartics.js">
<script src="./js/angulartics-ga.js"> ---- paths to these files are ok
Run Code Online (Sandbox Code Playgroud) 但是当我想创建该模块时:

var injector = angular.injector(['smsApp', 'ng']);
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

Uncaught Error: [$injector:unpr] http://errors.angularjs.org/1.2.15/$injector/unpr?p0=%24rootElementProvider%20%3C-%20%24rootElement%20%3C-%20%24location

没有Angulartics它很顺利!请帮帮我:)谢谢

我正在学习本教程.

javascript google-analytics angularjs angulartics

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

jquery检测并删除单击的元素

我有一个DIV的层次结构与类相关但不是ID.如何删除被点击的项目?

<div>
    <div class="minibox" onclick="remove_me()">Box1</div>
    <div class="minibox" onclick="remove_me()">Box1</div>
    <div class="minibox" onclick="remove_me()">Box1</div>
    <div class="minibox" onclick="remove_me()">Box1</div>
    <div class="minibox" onclick="remove_me()">Box1</div>
</div>
<script>
    function remove_me(){
    ///remove the clicked div
    }
</script>
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

容器中的中心文本(EaselJS)

我是EaselJS的新手,我正在尝试创建一个带有居中文本的彩色容器.这是我的代码:

var width = 100, height = 100;
canvas.width = width + 10;
canvas.height = height + 10;
var container = new c.Container();
container.x = 10;
container.y = 10;
container.setBounds(0, 0, width, height);

var rect = new c.Shape();
rect.graphics.beginFill('#6e7e8e').drawRect(0, 0, width, height);
container.addChild(rect);

var text = new c.Text();
text.set({
    text: 'hello',
    textAlign: 'center'
});
container.addChild(text);
stage.addChild(container);
stage.update();
Run Code Online (Sandbox Code Playgroud)

由于某种原因,文本不在容器中居中,但文本的一半不在容器中.我的代码有什么问题?

javascript canvas easeljs createjs

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

角度在Cordova上表现不同

我正在构建一个角度应用程序,其中有几个模块靠近john papas styleguide.接下来,我有几个独立的模块,有自己的路由定义,有些有拦截器.我的问题是:当我在Cordova/Android上运行时,当我将它们放在主模块中时,状态定义似乎才有效.在我的浏览器中工作.有没有人来过这个问题呢?

例如,这适用于本地浏览器和带有cordova的设备:

//main.js
'use strict';
angular.module('main', [
  'app.core',
  'auth'
])
.config(function ($stateProvider, $urlRouterProvider) {
  // ROUTING with ui.router
  $urlRouterProvider.otherwise('/main/list');
  $stateProvider
    // this state is placed in the <ion-nav-view> in the index.html
    .state('main', {
      url: '/main',
      abstract: true,
      templateUrl: 'main/templates/menu.html',
      controller: 'MenuCtrl as menu'
    })
  .state('main.login', {
    url: '/login',
    views: {
      'pageContent': {
        templateUrl: 'auth/templates/auth.login.html',
        controller: 'LoginCtrl'
      }
    }
  })
/* more states here */
Run Code Online (Sandbox Code Playgroud)

这仅适用于本地浏览器(与上面相同的主模块):

//auth.routes.js
'use strict';

angular
    .module('auth.routes')
    .config(config);

function config ($stateProvider) {
  $stateProvider …
Run Code Online (Sandbox Code Playgroud)

angularjs cordova angular-ui-router angular-http-interceptors

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

如何在包含ng-repeat的选择上触发ng-change

我有两个选择框,第二个选择框在第一个选择框更改时自动更新.

<label>Region</label>
<select ng-model="region" 
        ng-change="clear(1)" 
        ng-options="l.region for l in locations"
></select>
<br />
<label>Country</label>
<select ng-model='country'
        ng-change="clear(2)" 
        ng-options="c.country for c in region.countries"
></select>
Run Code Online (Sandbox Code Playgroud)

我的位置是一个json对象,如下所示:

[
  {region: "Europe", countries: [{country: "France"}, {country: "UK"}/*, ...*/]},
  {region: "Africa", countries: [{country: "Cameroon"}, {country: "Algeria"}]}
  /*, ...*/
]
Run Code Online (Sandbox Code Playgroud)

这一切都很好用.

当我想将第一个选择框的值设置为Europe时,它开始变得复杂,我想在第二个选择框上触发ng-change事件.

有关如何做到这一点的任何想法?

angularjs angularjs-ng-repeat

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

实现setTimeout本机方法

我正在研究facebook中的浏览器扩展,现在我的问题是facebook覆盖了setTimeout和setInterval本机函数,它们的实现在Internet Explorer上不起作用.

有没有办法实现这些功能?

javascript internet-explorer settimeout setinterval browser-extension

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

使用requireJS在全球范围内提供骨干模型和集合

我是Web应用程序开发的新手.我有一个名为LoginModel的骨干模型.我想创建它的一个对象,并使其可以从动态加载的任何Backbone View进行全局访问.这是我的模特..

define(['underscore', 'backbone'], function(_, Backbone) {
    LoginModel = Backbone.Model.extend({
        initialize: function(){ },
        defaults:{
            userName: 'undefined',
            userID: 'undefined'
        },
        urlRoot: 'https://xxxx.xx.xxxxxx',
        parse: function(response, options){
            return{
                userName: response.userName,
                userId:response.userId
            };
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

requirejs backbone.js backbone-views backbone-routing

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

在JavaScript中将Blob转换为文件列表

我正在使用以下代码将画布图像隐藏到Blob。
为了将Blob转换为文件/文件列表对象,我需要将该文件列表传递给文件处理程序。

我的代码:

var canvas1 = document.getElementById("preview");
var theImage = document.getElementById("blahProfile");
theImage.src = canvas1.toDataURL();
var blob = dataURItoBlob(theImage.src);
Run Code Online (Sandbox Code Playgroud)

有什么办法可以将该Blob转换为文件对象?

javascript blob filelist

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

将SVG转换为PNG/JPEG/BMP和反之亦然?

PHP中的代码将SVG转换为其他图像格式并且相反?

php svg image

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

如何在Javascript确认函数中传递参数?

我的代码中有类似的东西:

<?php foreach($clients as $client): ?>
    <tr class="tableContent">
        <td onclick="location.href='<?php echo site_url('clients/edit/'.$client->id ) ?>'"><?php echo $client->id ?></td>
        <td>
            <a class='Right btn btn-danger' onClick="ConfirmMessage('client', <?php $client->id ?>,'clients')">
                <i class="icon-remove-sign icon-white"></i>
            </a>
        </td>
    </tr>
<?php endforeach  ?>
Run Code Online (Sandbox Code Playgroud)

这实际上就是观点.因此,当用户点击删除按钮(使用btn-danger类时),我希望他通过javascript确认框消息确认他的选择.您可以在标题中找到该脚本

function ConfirmMessage(type, id, types) {
    if (confirm("Are you sure you want to delete this ",type," ?")) { // Clic sur OK
       document.location.href='<?php echo site_url(); ?>',types,'/delete/',id;
    }
}
Run Code Online (Sandbox Code Playgroud)

所以这是我的问题:

我想将$ type替换为我将传递给函数的参数(如客户端,文章,帖子......).我也想获得$client->id参数.我在javascript中很糟糕,正如你已经猜到的那样,它显然根本不起作用.

javascript php confirm

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