`
yanzhihong23
  • 浏览: 59816 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Passing data into a directive

 
阅读更多

 

<div my-directive
    my-url="http://google.com"
    my-link-text="Click me to go to Google"></div>

 

angular.module('myApp', [])
    .directive('myDirective', function() {
        return {
            restrict: 'A',
            replace: true,
            scope: { // isolate scope
                myUrl: '@', // binding strategy
                myLinkText: '@' // binding strategy
            },
            template: '<a href="{{myUrl}}">' +
                '{{myLinkText}}</a>'
        }
    })

 

myUrl: '@'    expects    my-url

if we want to use another attribute value, eg. some-attr, we can change to

myUrl: '=someAttr'

 

 

 

 

 

 

分享到:
评论

相关推荐

    JSP Simple Examples

    A directive is a way to give special instructions to the container at page translation time. The page directive is written on the top of the jsp page. Html tags in jsp In this example we have used ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    On the other hand, you must include the header file for Foo if your class subclasses Foo or has a data member of type Foo. Sometimes it makes sense to have pointer (or better, scoped_ptr) members ...

    The Art of Assembly Language Programming

    Chapter One Chapter One - Data Representation 1.0 - Chapter Overview 1.1 - Numbering Systems 1.1.1 - A Review of the Decimal System 1.1.2 - The Binary Numbering System 1.1.3 - ...

    php.ini-development

    Output buffering is a mechanism for controlling how much output data ; (excluding headers and cookies) PHP should keep internally before pushing that ; data to the client. If your application's ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - FIX: Removed FG_NEWTEXTROTATE directive (the TFlexText Precise mode should be used instead). - FIX: The TFlexRegularPolygon object clones incorrectly drawed in case when TFlexRegularPolygon have ...

    SystemVerilog for Design(2nd edition)

    2.4.1 Verilog’s timescale directive............................................................................28 2.4.2 Time values with time units ......................................................

Global site tag (gtag.js) - Google Analytics