小编Jos*_*ard的帖子

在Angular 2模板中呈现代码

我目前正在研究Angular 2应用程序,需要在Angular 2模板中显示一些C#代码,稍后将使用语法高亮显示器设置样式.

但是,只要我将代码放入Angular 2模板中,我就会在尝试解析C#并失败时得到模板解析错误.

zone.js:355 Unhandled Promise rejection: Template parse errors: <code>...

这是什么解决方案?Angular 2是否包含忽略模板代码部分的功能?

angular

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

无法建立连接,因为目标计算机在连接​​到 Azure IP 时主动拒绝它

连接到 Azure 活动目录服务(请参阅下面的代码)时,我立即收到错误消息:

No connection could be made because the target machine actively refused it 191.235.135.139:443

谷歌搜索 IP 后,它解析为位于爱尔兰的 Azure 数据中心。虽然真正奇怪的是随着 IP 不时变化,昨天 191.235.195.38:443 的 Azure IP 工作没有任何问题?

public partial class Startup
{
    public void ConfigureAuth(IAppBuilder app, HttpConfiguration config)
    {
        app.UseWindowsAzureActiveDirectoryBearerAuthentication(
            new WindowsAzureActiveDirectoryBearerAuthenticationOptions
            {
                Audience = CloudConfigurationManager.GetSetting("AzureActiveDirectoryInstance"),
                Tenant = CloudConfigurationManager.GetSetting("Tenant"),
                Provider = new QueryStringOAuthBearerProvider("AUTHORIZATION")
            });

        app.UseWebApi(config);
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经搜索了很多答案,尝试了一系列建议,例如检查没有使用端口 443(它告诉我目标机器主动拒绝连接的事实使我相信它能够到达机器)。

我认为这可能与 Azure 防火墙有关,但我有其他同事能够连接到同一公共 IP 地址上的服务。

有没有人在尝试连接到 Azure 服务时遇到过这种情况?

.net c# azure

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

通过Composer更新时不是git存储库错误

我正在尝试使用composer将我的Symfony 2项目从2.1.4更新到2.1.7并php composer.phar update正常运行,在更新了一些依赖项后,我收到以下错误:

[RuntimeException]
Failed to clone http://github.com/fabpot/Twig-extensions via git, https
and http protocols, aborting.

- git://github.com/fabpot/Twig-extensions
  fatal: Not a git repository (or any of the parent directories): .git

- https://github.com/fabpot/Twig-extensions
  fatal: Not a git repository (or any of the parent directories): .git

- http://github.com/fabpot/Twig-extensions
  fatal: Not a git repository (or any of the parent directories): .git
Run Code Online (Sandbox Code Playgroud)

我已经检查了URL并且可以确认它存在,我也能够在git clone没有任何问题的情况下使用相同的CLI.

奇怪的是,如果我php composer.phar update twig/extensions单独运行它似乎更新没有问题.

symfony composer-php symfony-2.1

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

一对多关系不起作用

在我的博客和我的blog_link_tag连接表之间创建一个简单的一对多关系时,我似乎遇到了问题.我几乎在那里但是我继续收到Doctrine的以下映射错误,我想知道是否有人能指出我哪里出错了?

The association Acme\BlogBundle\Entity\Blog#tags refers to the owning side field Acme\BlogBundle\Entity\BlogLinkTag#blog_id which does not exist.

下面是我正在使用的表结构,删除了不必要的字段.

CREATE TABLE `blog` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `blog_link_tag` (
  `id` int(3) NOT NULL AUTO_INCREMENT,
  `blog_id` int(3) NOT NULL,
  `tag_id` int(3) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Run Code Online (Sandbox Code Playgroud)

blog.php的

<?php

namespace Acme\BlogBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Blog
 *
 * @ORM\Table(name="blog")
 * @ORM\Entity(repositoryClass="Acme\BlogBundle\Entity\BlogRepository")
 * @ORM\HasLifecycleCallbacks …
Run Code Online (Sandbox Code Playgroud)

symfony doctrine-orm

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

在Angular 2中从父级调用子容器中的函数

我目前正在开发一个Angular 2应用程序,我正在尝试在子组件中调用一个函数,但似乎没有任何地方.

我的父组件如下所示:

app.component.ts

@Component({
    selector: 'piano-app',
    styleUrls: ['app/components/app/app.component.css'],
    template: `
        <div id="gameWrapper">
            <note-canvas [keyPressed]="pressed"></note-canvas>
            <piano (key-pressed)="keyPressed($event)"></piano>
        </div>
    `,
    directives: [PianoComponent, NoteCanvasComponent],
})
export class AppComponent {

    public pressed: any;

    // This event is successfully called from PianoComponent
    keyPressed(noteData) {
        console.log(noteData); // {key: 30, keyType: "white"}
        this.pressed = noteData;
    }
}
Run Code Online (Sandbox Code Playgroud)

和子组件看起来像这样:

注意,canvas.component.ts

export class NoteCanvasComponent implements OnInit {

    ...

    @Input() keyPressed : any;

    constructor(private element: ElementRef, private noteGenerator: NoteFactory) {
        this.canvas = this.element.nativeElement.querySelector('canvas');
        this.context = this.canvas.getContext('2d');
        this.canvasWidth = 900; …
Run Code Online (Sandbox Code Playgroud)

angular

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

难以使用Swing布局我的基本应用程序

我是Java的新手,我在过去的两个晚上都试图让我的Java程序正确布局,我希望有人可以为我清除一些东西.

布局一直顺利,直到我决定使用JMenuBar向我的应用程序添加菜单栏,现在由于某种原因,我的应用程序的菜单栏消失,附加到窗格的顶部中心,文件菜单栏的宽度,或工作完美但隐藏在它下面的按钮.

我最近的尝试让我更接近,但由于某种原因,当我将菜单栏容器设置为BorderLayout时,菜单栏的高度现在看起来很大.

任何人都可以指出我在哪里出错了吗?

JPanel mainPane = new JPanel();
BoxLayout progLayout = new BoxLayout(mainPane, BoxLayout.Y_AXIS);

mainPane.setLayout(progLayout);
setContentPane(mainPane);

JMenuBar menuBar = new JMenuBar();

JMenu file = new JMenu("File");
menuBar.add(file);

JMenuItem project = new JMenuItem("New Project");
JMenuItem exit = new JMenuItem("Exit");
file.add(project);
file.add(exit);

JPanel row0 = new JPanel();
BorderLayout menuBarLayout = new BorderLayout();
row0.setLayout(menuBarLayout);
row0.add(menuBar);
add(row0);


JPanel row1 = new JPanel();
row1.setOpaque(false);
row1.add(domainLabel);
row1.add(projectNameInput);
row1.add(userSubmit);
row1.add(userClear);
add(row1);
Run Code Online (Sandbox Code Playgroud)

非常感谢.

*编辑:由于以下答案,我终于设法让它工作.请参阅下面的评论解决方案.

java swing

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

无法使用Request类检索get参数

我有一个简单的博客包,其中包含以下路线:

blog_post:
    pattern:  /blog/{year}/{month}/{filename}/
    defaults: { _controller: ProjectBlogBundle:Post:index }
    requirements:
        year: "[0-9]{4}"
        month: "[0-9]{2}"
        filename: "([^/.]+)"
Run Code Online (Sandbox Code Playgroud)

哪个匹配网址symfony.local/blog/2012/04/hello-world/没有问题.但是由于某种原因,我无法使用Request类访问查询参数,如下所示:

use Symfony\Component\HttpFoundation\Request;

class PostController extends Controller
{
    /**
     * @Template()
     */
    public function indexAction(Request $request)
    {


    print_r($request->query->keys()); // outputs blank array
    print_r($request->request->keys()); // outputs blank array

    echo $request->get('filename'); // outputs hello-world

    ....

   }
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释为什么我无法访问查询参数使用$request->query->get('filename');

先感谢您.

symfony

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

标签 统计

symfony ×3

angular ×2

.net ×1

azure ×1

c# ×1

composer-php ×1

doctrine-orm ×1

java ×1

swing ×1

symfony-2.1 ×1