2015/09/29

AngularJS ng-href

ng-href用於a元素的超連結功能


<!DOCTYPE html>
<html>
  <head>
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
   <script type="text/javascript">
      var myApp = angular.module('myApp', []);
      myApp.controller('myController', function($scope){
          $scope.name = "霸氣資訊";
          $scope.url = "http://box7.tw";
      });
   </script>
   <meta charset="utf8"/>
   <title>Filter</title>
  </head>
  <body ng-app="myApp">
    <div ng-controller="myController">
      <a ng-href="{{url}}"><p ng-bind="name"></p></a>
    </div>
  </body>
</html>