2017年2月24日 星期五

利用 AngularJS 點表格 轉跳頁面

利用 AngularJS  點表格 轉跳頁面


<pre>
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">


<table >
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-click="myFunction()">
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>

</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.count = 0;
    $scope.myFunction = function() {
        window.location = "http://www.google.com";
    }
});
</script> 

</body>
</html>
</pre>


參考連結:
https://www.w3schools.com/angular/angular_events.asp
http://stackoverflow.com/questions/4744751/how-do-i-redirect-with-javascript
https://www.w3schools.com/html/html_tables.asp

沒有留言:

張貼留言