在子元素中使用ngFor的局部变量

时间:2016-03-07 15:25:59

标签: typescript angular ngfor

我想显示局部变量@Override public void onMessageReceived(String from, Bundle data) { super.onMessageReceived(from, data); String msg = data.getString("message"); Log.d(TAG,"GCM Message received is "+msg); // Notifying to user code goes here notifyUser(getApplicationContext(),msg); } public void notifyUser(Context context,String data){ Intent intent = new Intent(context, NotificationActivity.class); intent.putExtra("data", data); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(R.mipmap.ic_launcher); builder.setAutoCancel(true); builder.setContentTitle("New Notification"); builder.setContentIntent(pendingIntent); builder.setContentText(data); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Uri uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); builder.setSound(uri); notificationManager.notify(countNotification++, builder.build()); Log.v(TAG,"count "+countNotification); } 的属性,如theme

这就是我的theme.name看起来像

的方式
*ngFor

我也尝试使用<ul> <li *ngFor="#theme of themes"> <span>theme.name</span> </li> </ul> ,但这也不起作用。

1 个答案:

答案 0 :(得分:2)

如果

{{theme.name}}

不起作用,然后

{{theme?.name}}

可能会