角度隔离范围的问题 [英] Issue with Isolated scopes in angular

查看:68
本文介绍了角度隔离范围的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行该程序,但看不到任何输出.你能告诉我我在这里想念的东西吗?预先感谢.

I am trying to run this program and I see no output. Can you please let me know what I am missing here. Thanks in advance.

<html>
<head ng-app="myApp">
<title>Test</title>

<link rel="stylesheet"   href="//cdn.jsdelivr.net/foundation/4.3.2/css/foundation.min.css">
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script>

</head>
<body>
<div my-directive my-url="http://www.google.com" my-click="Click me">

</div>
</body>
<script>
angular.module('myApp',[]).directive('myDirective',function()
{
    return
    {
        restrict : 'AE',
        replace : true,
        scope :
        {
           myURL :'@',
           myClick : '@'
        },
        template : '<a href="{{myURL}}">{{myLinkText}}</a>'
    };
 });
</script>
</html>

推荐答案

似乎您已将Angular应用的根目录放置在标题中,而不是在正文中. 将ng-app="myApp"属性的位置从头部更改为 body html 元素

It looks like you placed the root of your Angular app in the header and not in the body. Change the location of the ng-app="myApp" attribute from the head to the body or html elements

<html ng-app="myApp"> <!-- new location -->
<head > <!-- ng-app="myApp" it was here -->
    <title>Test</title>

    <link rel="stylesheet"   href="//cdn.jsdelivr.net/foundation/4.3.2/css/foundation.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script>

</head>

指令{{myLinkText}}不存在,应将其重命名为{{myClick}}

In the directive {{myLinkText}} does not exists, it should be renamed for {{myClick}}

这篇关于角度隔离范围的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆