我有一个模板看起来像这样的组件:
..blabla
<img md-card-image src="..">
..blabla
Run Code Online (Sandbox Code Playgroud)
如何在component.ts中获取引用,以便我可以使用angular 4更改它的src?
错误:[$ compile:multidir]要求模板的多个指令[statbox,statbox]:
(在控制台上)
在index.html里面
<script src="js/dashboard/dashboard.module.js"></script>
<script src="js/dashboard/dashboard.component.js"></script>
<script src="js/dashboard/statbox.component.js"></script>
Run Code Online (Sandbox Code Playgroud)
在dashboard.module.js里面
var dashboardModule = angular.module('dashboard', ['ngRoute']);
Run Code Online (Sandbox Code Playgroud)
在dashboard.component.js内
angular.module('dashboard').component('dashboard', {
templateUrl: 'templates/dashboard/dashboard.template.html',
controller: ['$scope', '$routeParams', '$http', '$rootScope', '$log', function DashboardController($scope, $routeParams, $http, $rootScope, $log) {
...stuff NOT REFERENCING STATBOX by any means...
}]
});
Run Code Online (Sandbox Code Playgroud)
在statbox.component.js里面
angular.module('dashboard').component('statbox', {
templateUrl: 'templates/dashboard/statbox.template.html',
controller: ['$http', '$rootScope', '$log', function StatboxController($http, $rootScope, $log) {
... some random get request ...
}]
});
Run Code Online (Sandbox Code Playgroud)
在app.js里面
var app = angular.module('buttonMasher', ['ngRoute', …Run Code Online (Sandbox Code Playgroud) 在我的一个课程中,我有一个
Reservation * availability[30] = {nullptr};
Run Code Online (Sandbox Code Playgroud)
(我当然会在稍后用一些值初始化).
不过,我有一个getReservations()函数,它应该返回对30个元素的数组的引用,以便它可以像:
getReservations()[i] ...
Run Code Online (Sandbox Code Playgroud)
我该如何申报该功能?