我有一个复杂的模型结构(详见下文),每次我想使用时,ng-model
我都必须访问确切的属性,如下所示user.communications.inGame.selected
:
我希望能够确定一个区域的范围并能够在selected
没有所有前缀的情况下使用内部(简单地编写selected
),就像我能够使用ng-repeat
.
ng-repeat
不适合这里,因为每个通信内部都有不同的属性,而且我不希望ng-switch
它内部有一个巨大的。
数据结构
$scope.user.communications = {
inGame: {
name: 'inGame',
selected: true,
image: 'assets/img/communication/ingame.png'
},
teamspeak: {
name: 'teamspeak',
selected: true,
image: 'assets/img/communication/ts.png',
serverAddress: '',
port: '',
nickname: '',
password: '',
channel: '',
channelPassword: '',
autoBookmarkAdd: ''
},
skype: {
id: 3,
name: 'skype',
selected: true,
image: 'assets/img/communication/skype.png',
username: ''
},
ventrilo: {
name: 'ventrilo',
selected: true,
image: 'assets/img/communication/ventrilo.png',
serverName: '',
port: '',
serverPassword: '',
channelName: '',
channelPassword: ''
}
};