zoukankan      html  css  js  c++  java
  • angularjs中的ng-src和ng-href

    ng-src和ng-href等同于html中的src和href,只是ng是在dom加载完毕之后才能够发挥作用,如果在src或href中绑定变量,如果ng没有加载完,会导致链接地址出错,如果用对应的ng-src或ng-href,则不会出现这个问题。下面是一段示例代码:

    <!DOCTYPE html>
    <html ng-app="myApp">
    <head>
    <meta charset="UTF-8">
    <title>interval</title>
    <script type="text/javascript" src="angular.min.js" charset="utf-8"></script>
    </head>
    <body ng-controller="ctrl">
    
    <div><a ng-href="NewFile3_{{i}}.htm">链接</a></div>
    <div><input type="button" ng-click="clickEvent(1)" value="切换链接1" /><input type="button" ng-click="clickEvent(2)" value="切换链接2" /><input type="button" ng-click="clickEvent(3)" value="切换链接3" /></div>
    <script type="text/javascript">
    var myApp = angular.module('myApp',[]);
    myApp.controller('ctrl', function($scope){
        $scope.i = 1;
        $scope.clickEvent = function(index) {
            $scope.i = index;
        }
    });
    </script>
    </body>
    </html>
  • 相关阅读:
    leetcode 87. Scramble String
    leetcode 1278 分割回文串
    back propagation in NNs and RNNs
    刷题笔记——单调栈
    unsupervised learning -- K MEANS
    install j3d on macOS
    java extract jar file on MacOS
    back-propagation algorithm
    day 4
    day 3
  • 原文地址:https://www.cnblogs.com/modou/p/5868282.html
Copyright © 2011-2022 走看看