我试图渲染React元素的选项而没有选择。何可以做到这一点。此代码呈现选择元素和选项元素。在我的应用程序中,我使用AngularJs指令绑定选项,以便它复制选择视图。我怎样才能做到这一点 ?在ReactJs中渲染选项
return React.createElement('select',
timeSheet.map(function (time, index) {
var option = React.createElement('option', { value: time.value, key: index, label: time.lable, className: 'md-option' });
return option;
})
)
AngularJs指令。
angular.directive('timePicker', function() {
return {
restrict: 'A',
scope: {
ngValue: '='
},
link: function (scope, el, attrs) {
scope.$watch('ng-value', function (newValue, oldValue) {
var MyComponent = React.createFactory(GRID);
console.log(el[0])
ReactDOM.render(
MyComponent(),
el[0]
);
})
}
}
})
React类可以在这个链接的问题中找到。 GRID
谢谢。
你能告诉你的角码?此外,这可能是一个可怕的想法,因为你正在管理状态2非常不同(角度指令和反应组件) –