使用camelcase绑定路由angularjs组件对我不起作用,我不知道为什么。
下面是示例
组件
angular.
module('pdaFile').
component('pdaFile', {
templateUrl: 'app/myComponent/myComponent.html',
bindings:{
data:"<",
dataFileId:"@",
datafileid:"@",
id:"@"
},
controller: ['NgTableParams','UserAuthService',
function pdaFileController(NgTableParams,UserAuthService) {
var self=this;
...
self.$onInit = function () {
console.log(self.dataFileId); // undefined
console.log(self.id); // OK
console.log(self.datafileid); //OK
};
appConfig.js
..angular.
module('app')
.config(['$locationProvider', '$routeProvider',
function config($locationProvider, $routeProvider) {
$locationProvider.hashPrefix('!');
$routeProvider.
when('/pda', {
template: '<pda-file id="pippo" datafileid="current" data-file-id="current"></pda-file>'})
. 。。
我无法以任何方式填充绑定参数dataFileId。我试着用
<pda-file data-file-id="current"></pda-file>'
<pda-file dataFileId="current"></pda-file>'相反,非camelcase参数datafileid和id可以很好地工作。
有人能告诉我为什么吗?
发布于 2017-10-25 23:43:34
你试过了吗?
data-file-id="current"或
file-id="current"然后
bindings:{
fileId:"@",
}https://stackoverflow.com/questions/46910193
复制相似问题