在angular-fullstack中的”Hello World.”

我們將按照以下順序進行作業。

sudo yo
Angular Fullstackを選択し、Y/nで聞かれたオプションを全てYにしてscaffoldを生成する。
sudo yo angular-fullstack:route chat
'use strict';
/* eslint no-sync: 0 */
const angular = require('angular');

export class NavbarComponent {
  menu = [{
    'title': 'Home',
    'link': '/'
  },{
    'title': 'Chat',
    'link': '/chat'
  }];
  $location;
  isLoggedIn: Function;
  isAdmin: Function;
  getCurrentUser: Function;
  isCollapsed = true;

  constructor($location, Auth) {
    'ngInject';
    this.$location = $location;
    this.isLoggedIn = Auth.isLoggedInSync;
    this.isAdmin = Auth.isAdminSync;
    this.getCurrentUser = Auth.getCurrentUserSync;
  }

  isActive(route) {
    return route === this.$location.path();
  }
}

export default angular.module('directives.navbar', [])
  .component('navbar', {
    template: require('./navbar.html'),
    controller: NavbarComponent
  })
  .name;
<div ng-model="message">{{message}}</div>
'use strict';
const angular = require('angular');
const ngRoute = require('angular-route');


import routes from './chat.routes';

export class ChatComponent {
  /*@ngInject*/
  constructor($scope) {
    $scope.message = 'Hello World.';
  }
}

export default angular.module('testApp.chat', [ngRoute])
  .config(routes)
  .component('chat', {
    template: require('./chat.html'),
    controller: ChatComponent,
    controllerAs: 'chatCtrl'
  })
  .name;

gulp serve
http://localhost:3000/chat にアクセスする。
广告
将在 10 秒后关闭
bannerAds