小编use*_*401的帖子

在AngularJS中使用Bootstrap工具提示

我试图在我的应用程序中使用Bootstrap工具提示.我的应用程序正在使用AngularJS目前,我有以下内容:

<button type="button" class="btn btn-default" 
        data-toggle="tooltip" data-placement="left"
        title="Tooltip on left">
            Tooltip on left
</button>
Run Code Online (Sandbox Code Playgroud)

我想我需要用

$("[data-toggle=tooltip]").tooltip();
Run Code Online (Sandbox Code Playgroud)

但是,我不确定.即使我添加上面的行,我的代码也不起作用.我试图避免使用UI引导程序,因为它比我需要的更多.但是,如果我只需要提供工具提示,我就会对此持开放态度.然而,我无法弄清楚如何做到这一点.

有人可以告诉我如何让Bootstrap Tooltip与AngularJS一起使用吗?

twitter-bootstrap angularjs twitter-bootstrap-tooltip

89
推荐指数
6
解决办法
18万
查看次数

如何运行量角器

我是AngularJS的新手.我正在尝试学习并使用Protractor进行一些端到端的测试.我一直在浏览这里提供的信息.当我到达"Run with protractor myConf.js" 部分时,我陷入了困境.

量角器是命令行程序吗?或者是什么?我想要确定的是,在什么环境下我需要运行"量角器myConf.js".我不想全局安装量角器.我想在本地环境中运行该模块.这是一个选择吗?

谢谢,

angularjs protractor

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

Bootstrap工具提示不显示

我试图在我的应用程序中使用Bootstrap 工具提示.目前,我有以下内容:

<button type="button" class="btn btn-default" 
        data-toggle="tooltip" data-placement="left"
        title="Tooltip on left">
            Tooltip on left
</button>
Run Code Online (Sandbox Code Playgroud)

不幸的是,我的工具提示没有显示.我想弄清楚我做错了什么.我知道它可以通过JavaScript创建.但是,我正在尝试以声明方式定义我的工具提示.我已经确认包含了Tooltip.js文件.但是,我无法弄清楚我做错了什么.

是否可以在纯粹的声明意义上使用工具提示?如果是这样,有人可以通过JSFiddle或Bootply样本向我展示如何?我真的在敲打这个.

jquery tooltip twitter-bootstrap

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

AngularJS指令价值

我有一个AngularJS指令.我的指令仅限用作属性.但是,我想获取属性的值.目前,我的属性定义为:

angular.module('myDirectives.color', [])
    .directive('setColor', function () {
        return {
            retrict: 'A',
            link: {
                pre: function () {
                    console.log('color is: ');
                }
            }
        };
    })
;
Run Code Online (Sandbox Code Playgroud)

我以下列方式使用该属性:

<button type="button" set-color="blue">Blue</button>
<button type="button" set-color="yellow">Yellow</button>
Run Code Online (Sandbox Code Playgroud)

我知道我的指令正在被使用,因为我看到'颜色是:'但是,我无法弄清楚如何在控制台语句的末尾显示"蓝色"或"黄色".我想获得该值,以便我可以进行条件处理.如何获取属性的值?

谢谢!

angularjs angularjs-directive

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

Node.js +使用RESTIFY服务静态文件

我在站点中有.html,.js,.png,.css等文件的多级集合.看看我的网站hiearchy如下所示:

index.html
child1
  index.html
  page1.html
  page2.html
  ...
child2
  grandchild1
    index.html
  grandchild2
    index.html
  index.html
  page1.html
  page2.html
resources
  css
    myTheme.css
  img 
    logo.png
    profile.png
  js
    jquery.js
    ...
...
Run Code Online (Sandbox Code Playgroud)

我正在迁移它以在Node.js下运行.我被告知我必须使用RESTIFY.目前,我已经为我的服务器编写了以下内容:

var restify = require('restify');
var fs = require('fs');
var mime = require('mime');

var server = restify.createServer({
    name: 'Demo',
    version: '1.0.0'
});

server.use(restify.acceptParser(server.acceptable));
server.use(restify.queryParser());
server.use(restify.bodyParser());

server.get('/', loadStaticFile);

server.get('/echo/:name', function (req, res, next) {
    res.send(req.params);
    return next();
});

server.listen(2000, function () {
    console.log('Server Started');
});

function loadStaticFile(req, res, next) {
    var filePath = __dirname + getFileName(req); …
Run Code Online (Sandbox Code Playgroud)

node.js restify

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

从Grunt执行PowerShell脚本

我有一个PowerShell脚本(myScript.ps1),我需要在构建过程中运行它.我正在使用Grunt来构建我的代码.我无法弄清楚如何从Grunt运行这个脚本.有谁知道如何从Grunt运行PowerShell脚本,以便在PowerShell脚本完成之前下一个任务不会运行?

谢谢!

powershell gruntjs

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

AngularJS - 按属性值查找元素

我正在尝试使用AngularJS来查询我的视图的DOM.我需要获得所有具有'data-placement'属性的元素,其值为'top'.在jQuery中,我会这样做:

var elements = $('[data-placement="top"]');
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何使用AngularJS.谁能告诉我怎么做?

谢谢!

dom angularjs

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

JavaScript - 检查变量是否存在

我有一个名为index.js的JavaScript文件.此javascript文件提供与index.html关联的过程代码.我的index.html文件非常基础.它看起来如下:

<!DOCTYPE html>
<html>
    <body>
        <script type="text/javascript" src="index.js"></script>
        <script type="text/javascript">
@if (ViewBag.IsGood()) {
  <text>
            INFORMATION = { version: '<%= version%>', timestamp: '<%= timestamp%>' };
  </text>
}
          runInit();
        </script>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

在我的index.html.js文件中,我有以下内容

function runInit() {
  if (INFORMATION === undefined) {
    INFORMATION = { version: 'Unknown' };
  }

  // Keep going 
}
Run Code Online (Sandbox Code Playgroud)

如您所见,有时会设置信息.有时,它没有.设置信息时一切正常.如果未设置,则会收到错误消息"ReferenceError:找不到变量:INFORMATION".我对此感到困惑,因为我认为我正在检查该属性是否存在正确.显然,我不是.

在JavaScript中,如何确保变量存在?这是我最关心的问题.我不想重新安排我的代码.我真的想这样做.我觉得我做得对.但是,我仍然收到错误.

谢谢.

javascript

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

使用Jasmine进行端到端测试

我正在尝试对使用AngularJS编写的应用程序执行一些端到端测试.目前,我在e2e.tests.js中设置了以下测试:

describe('MyApp', function() {
    beforeEach(function() {
        browser().navigateTo('../index.html');
    });

    it('should be true', function() {
        expect(true).toBe(true);
    });
});
Run Code Online (Sandbox Code Playgroud)

奇怪的是,这个基本测试失败了.测试本身就运行了.但结果是:

203ms   browser navigate to '../index.html'
5ms expect undefined toBe true
           http://localhost:81/tests/e2e.tests.js:10:9
           expected true but was undefined
Run Code Online (Sandbox Code Playgroud)

考虑到"真实"是硬编码的,我希望它通过这个测试.我不知道未定义的真实性.我错过了什么?

jasmine angularjs

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