में कस्टम के निर्देश के नियंत्रक के दायरे जाओ मैं पहुंच क्षेत्र नियंत्रक के साथ संलग्न की कोशिश कर रहा हूँ ** अपने कस्टम कोणीय निर्देश ** जब चमेली में परीक्षण।जैस्मीन परीक्षण
app.directive('MyDirective', function(){
return {
template:...,
scope:...,
controller: function($scope){
$scope.clickMe = function() {
....
};
$scope.message = "";
}
}
मैं क्लिकमे विधि में परिभाषित किया गया है या नहीं, यह सत्यापित करने के लिए मैं जैस्मीन में एक परीक्षण लिखना चाहता हूं।
it('should have 3 methods', function() {
expect(dscope).not.toBe(null);
expect(scope).not.toBe(null);
expect(angular.isFunction(dscope.clickMe)).toBe(true);
expect(dscope.message).toBe(true); }
beforeEach में() मैं इस प्रकार गुंजाइश और dscope चर की घोषणा की:
beforeEach(inject(function( $rootScope, $compile){
scope = $rootScope.$new();
element = angular.element("<div my-directive></div>");
//bind the empty scope into the directive
$compile(element)(scope);
//access to internal directive scope of our element
dscope = element.scope(); }));
लेकिन जब मैं परीक्षण चलाने के लिए, मैं * और उम्मीद "सच झूठी उम्मीद करते हैं।" आप कोणीय 1.2+ उपयोग कर रहे हैं scope.message
बहुत बहुत शुक्रिया! मैं उन सभी उदाहरणों से पागल हो रहा था जो काम नहीं करेंगे !! – achedeuzot
प्रश्न और उत्तर के लिए धन्यवाद :) –